iwyg / apipage

API Frontend Page
7 stars 7 forks source link

JSON Arrays #4

Open korelogic opened 10 years ago

korelogic commented 10 years ago

Hi,

How can i output single object arrays like this?

array : [ { date : 2013-05-11 value : 123 } ]

what i get is:

array : { date : 2013-05-11 value : 123 }

iwyg commented 10 years ago

Unfortunately you can't do this on a single object because the converter isn't aware of what your data is supposed to look like. Basically, if there're multiple child-nodes with the same name, the converter will parse them into an array, whereas if there's only one child treats that as a single element. There's no way in xml to indicate that the supposed output has to be "arrayish", maybe it'd be helpful to trigger an array like structure by certain keywords, but I think that'd be more confusing than helpful.