RejectedSoftware Forums

Sign up

How can I append to json arrays ?

Well the topic says it all.

Let's assume I have the following JSON-Object
{ "ID":"3" }
and I have an JSON-Array of thoose objects
[ {"ID":"1"}, {"ID":"2"} ]
I want to get
[ {"ID":"1"}, {"ID":"2"}, {"ID":"3"} ]

How do I do it ?

Re: How can I append to json arrays ?

On Mon, 03 Feb 2014 19:37:05 GMT, Stefan Koch wrote:

Well the topic says it all.

Let's assume I have the following JSON-Object
{ "ID":"3" }
and I have an JSON-Array of thoose objects
[ {"ID":"1"}, {"ID":"2"} ]
I want to get
[ {"ID":"1"}, {"ID":"2"}, {"ID":"3"} ]

How do I do it ?

I found an workaround for me.
just convert my Object to an array by perpending '['
and appending ']'

not pretty though