Hi there.
I'm sending data to a server, and the server passes a json object back into httpresponse.
I'm trying to assign that response to a variable..
to use something like data.username
Also tried
Or are the only way to work with the object, to use it as is? ie:
Cause if I use it like that, I get "undefined"
Anyone want to help this newbie out?
ps. The JSON data from the server looks like this:
Which I believe is good Json data?
Hello fakie,
I think this:
Must be something like this:
Anyway, your JSON response is an Array, and you must deal with that using the Array related actions. Apparently your response contains only one JSON object in the Array, so probably you can use the "ArrayGetItem" action like below:
Once you do that you can access the JSON object's properties using the specified variable like below:
On the other hand, if we are talking about your server and then you control the response, try to send a JSON object directly, not inside any Array, then you can access the JSON data in a more easy way. In fact you no need JSON at all, that is, you can also use another kind of response.
For example, a possible response can be certain string ready to be passed as the argument of the "ParseVariables" action. Then your response can be directly put inside your desired app's variables. Take a look if you wanted at the "LoadVars*" and "ParseVars" samples.
Great.
Exactly what I need.
So if I more than one JSON object, I would use a "1" or a "2" where the "0" is at the moment?
ArrayGetItem "[HttpClient.Response]" "0" "[JSONObject]"
Hello Fakie,
Great. Exactly what I need.
So if I more than one JSON object, I would use a "1" or a "2" where the "0" is at the moment?
Absolutely. You can use all the Array related actions, so you can iterate over the Array, for example:
Everybody can read the DecSoft support forum for learning purposes, however only DecSoft customers can post new threads. Purchase one or more licenses of some DecSoft products in order to give this and other benefits.