I’ve got the following… which calls the following.. However, my code never reaches “ZOMG HERE” but rather throws the following error while running chrome.extension.sendRequest Does anyone have any idea what is causing this? Answer It means that the object you pass in the request (I guess it is pagedoc) has a circular reference, something like: JSON.stringify cannot convert structures like
Tag: json
Finding the max value of an attribute in an array of objects
I’m looking for a really quick, clean and efficient way to get the max “y” value in the following JSON slice: Is a for-loop the only way to go about it? I’m keen on somehow using Math.max. Answer To find the maximum y value of the objects in array: or in more modern JavaScript:
What is JSONP, and why was it created?
I understand JSON, but not JSONP. Wikipedia’s document on JSON is (was) the top search result for JSONP. It says this: JSONP or “JSON with padding” is a JSON extension wherein a prefix is specified as an input argument of the call itself. Huh? What call? That doesn’t make any sense to me. JSON is a data format. There’s no
jQuery: Possible to wait for $.get to finish loading before continuing?
The folowing script does not wait for $.get to finish loading the page before continuing with the loop: data is a JSON object Any ideas or comments will be greatly appreciated. Answer That should do it. Old docs 2021 docs
JSON: why are forward slashes escaped?
The reason for this “escapes” me. JSON escapes the forward slash, so a hash {a: “a/b/c”} is serialized as {“a”:”a/b/c”} instead of {“a”:”a/b/c”}. Why? Answer JSON doesn’t require you to do that, it allows you to do that. It also allows you to use “u0061” for “A”, but it’s not required, like Harold L points out: The JSON spec says
JSON Stringify changes time of date because of UTC
My date objects in JavaScript are always represented by UTC +2 because of where I am located. Hence like this Problem is doing a JSON.stringify converts the above date to What I need is for the date and time to be honoured but it’s not, hence it should be Basically I use this: I tried passing a replacer parameter (second
Merge keys array and values array into an object in JavaScript
I have: And I’d like to convert it into this object: In Python, there’s the simple idiom dict(zip(keys,values)). Is there something similar in jQuery or plain JavaScript, or do I have to do this the long way? Answer Simple JS function would be: Of course you could also actually implement functions like zip, etc as JS supports higher order types