JSON loader
Basics
The JSON loader allows you to access attributes or sub-elements of the input JSON the following way.
Let's take an example JSON:
{
complexobject: {
someobject: {
something: "duh"
},
elements: [
{
id: "id01",
data: {
value: "Hello",
index: 1
},
details: [
{ detail: "a" },
{ detail: "b" }
]
},
{
id: "id02",
data: {
value: "Goodbye",
index: 2
}
}
]
}
}
If your parser takes elements
as root, then two sets of data will be generated (one for every item in the "elements" array above):
The first element will contain the following fields/values :
id
= "id01"data.value
= "Hello"data.index
= 1details.detail
= ["a","b"] (multivalued - see note below)
And the second element :
id
= "id02"data.value
= "Goodbye"data.index
= 2
If the root element is not a direct child of the root, you can also access it with a standard dotted syntax, i.e. elementFromRoot.subelement.arrayElement
, to access the right array:
{
elementFromRoot: {
subelement: {
arrayElement: [
<what really matters>
]
},
ignoredElements: {
...
}
},
otherIgnoredElements: {
...
}
}
If the JSON root is an array itself, then you may leave the root element empty.
Multivalued fields
Note that in the first element, the field details.detail
will be multivalued, meaning that if you use it in your template, the related entity may be cloned.