rest - Array of objects using IODOCS -
i want add array of object like
"identifiers": [ { "primary": true }, { "primary": false }, ]
but object inside array need name create like
"identifiers": [ { "identifier": { "primary": true } } ]
i used following json code in config file,
"identifiers": { "title": "identifiers", "type": "array", "location": "body", "items": { "title": "identifier fields", "type": "object", "properties": { "identifier": { "type": "object", "properties": { "primary": { "title": "primary", "required": true, "type": "boolean", "description": "", "default": true } } } } } }
how achieve this. kindly me.
thanks in advance.
you can this
data = {"identifiers": [ { "primary": true }, { "primary": false }, ]}; for(i=0;i<data.identifiers.length;i++) { obj = data.identifiers[i]; obj = { "identifier": { "primary": obj.primary } }
//if want properties of obj means have loop through create them. go through copying properties }
Comments
Post a Comment