JSON Stringify Returns Empty String
In Javascript I try to use stringify but it keeps returning an empty string. What is wrong here? Feel free to edit the Fiddle. JS values = []; values['belopp'] = 2322; values['test
Solution 1:
You are trying to use something that is meant for an object on an array.
values = {};
values['belopp'] = 2322;
values['test'] = 'jkee';
str = JSON.stringify(values);
This is the updated fiddle.
Solution 2:
You are stringifying an array ([])
, not an object ({})
Therefore, values = {};
Post a Comment for "JSON Stringify Returns Empty String"