javascript - JSON left out Infinity and NaN; JSON status in ECMAScript?

Infinity and NaN aren't keywords or anything special, they are just properties on the global object (as is undefined) and as such can be changed. It's for that reason JSON doesn't include them in the... Read More

Display JSON as HTML

You can use the JSON.stringify function with unformatted JSON. It outputs it in a formatted way. JSON.stringify({ foo: "sample", bar: "sample" }, null, 4) This turns { "foo": "sample", "bar": "samp... Read More

javascript - Loading local JSON file

$.getJSON is asynchronous so you should do: $.getJSON("test.json", function(json) { console.log(json); // this will show the info it in firebug console });... Read More

json - json_encode/json_decode - returns stdClass instead of Array in PHP

Take a closer look at the second parameter of json_decode($json, $assoc, $depth) at https://secure.php.net/json_decode... Read More

How to convert XML to JSON in Python?

xmltodict (full disclosure: I wrote it) can help you convert your XML to a dict+list+string structure, following this "standard". It is Expat-based, so it's very fast and doesn't need to load the who... Read More

jquery - Pass array to ajax request in $.ajax()

info = []; info[0] = 'hi'; info[1] = 'hello'; $.ajax({ type: "POST", data: {info:info}, url: "index.php", success: function(msg){ $('.answer').html(msg); } });... Read More

jquery - Why is my json file not found?

Have you tried removing the ~ ? As in: $.getJSON('/Content/dumboJr.json', function (data) { $.each(data, function(i, dataPoint) { // Bla }); }); ) To allow the IIS to serve JSON f... Read More

ajax - POST JSON fails with 415 Unsupported media type, Spring 3 mvc

I've had this happen before with Spring @ResponseBody and it was because there was no accept header sent with the request. Accept header can be a pain to set with jQuery, but this worked for me sourc... Read More

javascript - Get total number of items on Json object?

In addition to kieran's answer, apparently, modern browsers have an Object.keys function. In this case, you could do this: Object.keys(jsonArray).length; More details in this answer on How to list th... Read More

java - Is default no-args constructor mandatory for Gson?

As of Gson 2.3.1. Regardless of what the Gson documentation says, if your class doesn't have an no-args constructor and you have not registered any InstanceCreater objects, then it will create an Obj... Read More