How to pass a JSON array as a parameter in URL

前端 未结 9 1226
一整个雨季
一整个雨季 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条回答
  •  情深已故
    2020-11-28 11:01

    I would suggest to pass the JSON data in the body as a POST request.But if you still want to pass this as a parameter in URL,you will have to encode your URL like below just for example:-

    for ex json is :->{"name":"ABC","id":"1"}

    testurl:80/service?data=%7B%22name%22%3A%22ABC%22%2C%22id%22%3A%221%22%7D

    for more information on URL encoding refer below

    https://en.wikipedia.org/wiki/Percent-encoding

提交回复
热议问题