Send JsonArray through WWW

I’d like to know if there was a way to send to an api some data as json array it would be somethink like :
" form.AddField (“rushes”, json [“rushes”].ToString ());"

But this doesn’t work.

Any Idea?

Regards,

JSON is also a string, with a specific formatting so other json tools can decode and use it. But you’re simply using the value of json[“rushes”] and not the whole json array. You need to add the whole array as string to the form.
Something like that:

var jsonString = json.ToJsonString();    // You need to use a json Function that formats your array into a json object
form.AddField("jsonArray", jsonString);

google for simpleJson or any other scripts from that you can use the decode/encode functions to get an json object from string and vice versa.

Unity also has their own json system in place that you can use, depending on the version of unity you are on, so you can look into that as well.

1 Like