Json Decoding Issue

Hi,

I am few weak in js / ajax / json. However, I have a string as ajax response through firebug console that is:




Order%5Bitem_list%5D%5B%5D=5&Order%5Bitem_list%5D%5B%5D=6



is there any way to receive the value of this string that is "Order%5Bitem_list%5D%5B%5D"

Or actually, I do not understand about the string?

Thanks in advance if someone help to understand and handle this string.

That looks like a URL string, not a JSON. If you want to make a JSON out of it, you first need to URL decode it, then use that data.

I don’t know if Yii includes a class to decode it, but if it doesn’t you can try the urldecode function.

It will give you something like


Order[item_list][]=5&Order[item_list][]=6

With that string, you can do whatever you want. If you wanted to decode a JSON, I guess you wanted to make an array out of it. In which case, you can use the explode function, and separate it with the "&" character, resulting in something like




Array(

[0]=>"Order[item_list][]=5",

[1]=>"Order[item_list][]=6"

)



Depends on what you need.

it is javascript built in function, you can use this :

decodeURI(uri)

study for detail information:

http://www.w3schools.com/jsref/jsref_decodeuri.asp

thanks ASPtoYiiDev and Mubashar Iqbal to help me. I’ll try by myself, ask if I face any difficulties.

Hi I need to use the value 5,6. How to extract these values. Could you help me?