Url format in a json query string Url format in a json query string json json

Url format in a json query string


What is the format of this string?

If you used the data: {...} format then it will be sent as application/x-www-form-urlencoded format which is:

key1=value1&key2=value2...

Example:

$.getJSON('http://<domain:port/path/something.html', { key1: 'value1', key2: 'value2' }, function(result) {});

I see a url of this format coming from such a jquery json call from client side: http://<domain:port/path/something.html?somevalue=a;othervalues=1,2,3,4;v=3

This is query is not sent using the data parameter but probably directly hardcoded in the url (first parameter of the getJSON method):

$.getJSON('http://<domain:port/path/something.html?somevalue=a;othervalues=1,2,3,4;v=3', function(result) {});

Or they provided the data as string and not as key/value pair:

$.getJSON('http://<domain:port/path/something.html', 'somevalue=a;othervalues=1,2,3,4;v=3', function(result) {});


What is the format of this string?

The property can be given a value of either an object or a string.

If it is given an object, then its keys and values will be formatted as application/x-www-form-urlencoded data (just like a form submission).

If it is given a string, it will be whatever that string is — so it can be "Whatever the author of the code using it wants it to be".

I see a url of this format…

That would be a case of "Whatever the author wants". Note that ; and & can be used interchangeably in a number of application/x-www-form-urlencoded decoding libraries. This is recommended by the HTML 4 specification.

Is this format specific to json?

No. There is no connection between the data format of the URL used to make a request and the data format of the response.