Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should a JSON response from a REST API be url-encoded?

Tags:

json

rest

I am developing a RESTful API which will operate through JSON messages, both received and sent.

The question is, when I return the result of an API call as application/json, should the response also be URL-encoded?

For example, is it more correct

{"status":"OK","id":"WjY3T2g2Z1JGV1dFcXRqcXh4TDBlNnd1bHlwMVVLVzBRWnU1TTBnWGwrUEFKTHd5RlZSSytRMmdMTnlBS1ViUg%3D%3D"}

or

{"status":"OK","id":"WjY3T2g2Z1JGV1dFcXRqcXh4TDBlNnd1bHlwMVVLVzBRWnU1TTBnWGwrUEFKTHd5RlZSSytRMmdMTnlBS1ViUg=="}
like image 305
Matteo Tassinari Avatar asked Oct 28 '25 11:10

Matteo Tassinari


1 Answers

As the name suggests url encoding is for URL's so there's no need to apply it to your JSON, unless, the value is a URL.

like image 194
Martin Avatar answered Oct 31 '25 01:10

Martin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!