I have a JSON document that I want to transform into triples. Among the JSON elements is an element that contains a set of arrays, in roughly this format:
I can describe the FROM JSON mappings for the two simple JSON elements, but not sure what the SMS2 encoding for the Contact JSON element that contains a list of arrays. My attempts so far yield parsing errors.
You can specify arrays in the mapping source using the square brackets as normal. If they're scalar, specify a variable name in quotes. If they're object, then you should nest the object fields, eg.
Jess and Daniel, thanks for your help! I was able to resolve my issue with your advice. Is there more documentation that describes SMS options? For example, I want to append a random number to an IRI for each instance of an array, defined in the WHERE clause of the SMS script. For example:
I know two ways to generate a random value but they are really different.
bnode()
The first one is the bnode function. That function generates everytime a random, unique and new blank node. You can use it as IRI. You use the bnode function in a bind and the syntax is simply
bind(bnode() as ?blankNode)
rand()
The second one is the rand function that generate a random number between 0 and 1. But the result is not unique. Be careful about that. You also use it in a bind as in:
bind(rand() as ?randomNumber)
Also, as that second option does not generate a complete IRI and you need to do the assembly with something else as:
bind(concat(?customerId, "-", ?randomNumber) as ?shortIRI)
And after that, you use the template function as you are right now. But remember, the generated number is not unique.
Note
If you really don't care about the generated IRI, you should use the bnode function. You can count on it to generate something unique.
You can also use a part of your address to generate a hash value and use it to complete your IRI.
The following code will generate a nice GUID you can use:
BIND(replace(md5(?mergedAddressFields),"^(\\w{8})(\\w{4})(\\w{4})(\\w{4})",'$1-$2-$3-$4-') as ?guid)
But I wouldn't use the rand function as the value is not unique.