How to pass a JSON array as a parameter in URL

前端 未结 9 1225
一整个雨季
一整个雨季 2020-11-28 10:35

I have an requirement to pass a some values from mobile to server in a web service call and so I am planning to pass all the values in JSON format like the below

<         


        
9条回答
  •  -上瘾入骨i
    2020-11-28 10:59

    I know this could be a later post, but, for new visitors I will share my solution, as the OP was asking for a way to pass a JSON object via GET (not POST as suggested in other answers).

    1. Take the JSON object and convert it to string (JSON.stringify)
    2. Take the string and encode it in Base64 (you can find some useful info on this here
    3. Append it to the URL and make the GET call
    4. Reverse the process. decode and parse it into an object

    I have used this in some cases where I only can do GET calls and it works. Also, this solution is practically cross language.

提交回复
热议问题