Hi,
I find it's difficult to make the Type definition for the json sample data below since the two arrays {} do not have any names.
"ParameterGroup":[{"Name": "String",
"Parameter": [ arrays ]
},
{"Name": "String",
"Parameter": [ arrays ],
"ParameterGroup": [ arrays ]
}
]
What kind of Type definition shall be for the json array data without names?
Thanks.
Hi Yanyang,
Do you want to derive the type definition in IDL or XML format from the JSON sample description?
If you want need to have a JSON array composed objects, like in your example; you need to define in your IDL an array or a sequence of a complex type, like a Structure. That structure will contain all the fields of the JSON object within the array. For example:
In the example before you have MyStruct, which is the top-level type that you can read or write. That has an field called ParameterGroup that is a sequence of ParameterGroupItems (you could also define ParameterGroup as an array instead).
If you represent a sample for that type definition using JSON, you get something like:
That is, a JSON object representing the top level type, a ParameterGroup array of ParameterGroupItems, and a property called Name in every JSON object representing the ParameterGroupItem.
If you want to nest arrays with objects, like in your example, you have to repeat the process with nested elements.
Is this what you were looking for?
Thanks,
Fernando
Hi Fernando,
I forgot to mention that I wanted to make the type definition in XML format. But I have solved this problem by myself. Thank you for the kind reply!
Hi Yanyang,
Great! I am glad to hear you were able to solve your problem.
Just for reference for those who might find this post looking for a similar solution, the equivalent definition in XML format would be:
Best regards,
Fernando.