All Questions
338
questions
1382
votes
23
answers
1.8m
views
Convert JS object to JSON string
If I defined an object in JS with:
var j={"name":"binchen"};
How can I convert the object to JSON? The output string should be:
'{"name":"binchen"}'
23
votes
13
answers
25k
views
Sum JavaScript object propertyA values with the same object propertyB in an array of objects
How would one take a JavaScript array of objects, such as
objArr = [
{key:"Mon Sep 23 2013 00:00:00 GMT-0400", val:42},
{key:"Mon Sep 24 2013 00:00:00 GMT-0400", val:78},
...
86
votes
12
answers
191k
views
Parsing JSON in Excel VBA
I have the same issue as in Excel VBA: Parsed JSON Object Loop but cannot find any solution. My JSON has nested objects so suggested solution like VBJSON and vba-json do not work for me. I also fixed ...
8
votes
3
answers
13k
views
Array of JSON Object to Java POJO
Converting this JSON object as a class in java, how would the mapping be in your POJO Class?
{
"ownerName": "Robert",
"pets": [
{
"name": "Kitty"
},
{
...
301
votes
11
answers
1.1m
views
Converting Java objects to JSON with Jackson
I want my JSON to look like this:
{
"information": [{
"timestamp": "xxxx",
"feature": "xxxx",
"ean": 1234,
"data": "xxxx"
}, {
"timestamp": "yyy",
...
74
votes
6
answers
93k
views
Why is JSON invalid if an integer begins with a leading zero?
I'm importing some JSON files into my Parse.com project, and I keep getting the error "invalid key:value pair".
It states that there is an unexpected "8".
Here's an example of my JSON:
}
"...
128
votes
9
answers
203k
views
Difference between JSON object and JSON array
After having a short look at Google I found this link that describes the difference between a JSON object and a JSON array, yet from a syntax point of view.
When would one be used over the other in a ...
218
votes
16
answers
283k
views
Parse JSON String into a Particular Object Prototype in JavaScript
I know how to parse a JSON String and turn it into a JavaScript Object.
You can use JSON.parse() in modern browsers (and IE9+).
That's great, but how can I take that JavaScript Object and turn it ...
60
votes
14
answers
49k
views
Merge keys array and values array into an object in JavaScript
I have:
var keys = [ "height", "width" ];
var values = [ "12px", "24px" ];
And I'd like to convert it into this object:
{ height: "12px", width: "24px" }
In Python, there's the simple idiom dict(...
232
votes
5
answers
303k
views
Which characters are valid/invalid in a JSON key name?
Are there any forbidden characters in key names, for JavaScript objects or JSON strings? Or characters that need to be escaped?
To be more specific, I'd like to use "$", "-" and space in key names.
141
votes
9
answers
104k
views
Determine whether JSON is a JSONObject or JSONArray
I am going to receive either a JSON Object or Array from server, but I have no idea which it will be. I need to work with the JSON, but to do so, I need to know if it is an Object or an Array.
I am ...
167
votes
20
answers
592k
views
Convert object string to JSON
How can I convert a string that describes an object into a JSON string using JavaScript (or jQuery)?
e.g: Convert this (NOT a valid JSON string):
var str = "{ hello: 'world', places: ['Africa', '...
320
votes
15
answers
623k
views
How to get object length [duplicate]
Is there any built-in function that can return the length of an object?
For example, I have a = { 'a':1,'b':2,'c':3 } which should return 3. If I use a.length it returns undefined.
It could be a ...
22
votes
6
answers
106k
views
Sorting a JSON object in Javascript
I've been looking for a while to sort a JSON object like this
{"results": [
{
"layerId": 5,
"layerName": "Pharmaceutical Entities",
"attributes": {
"OBJECTID": "35",
"...
105
votes
11
answers
174k
views
Serializing PHP object to JSON
So I was wandering around php.net for information about serializing PHP objects to JSON, when I stumbled across the new JsonSerializable Interface. It's only PHP >= 5.4 though, and I'm running in a 5....