I want to convert my object into a JSON String where the root element should be the name of my object. var data = { name: 'qwertz', age: 23, skills: [ 'html', 'css'
Solution 1:
As simple as that:
var json = JSON.stringify({ data: data });
Solution 2:
Try this
JSON.stringify({'data':data})
Share
Post a Comment
for "Json.stringify Set Root Element"
Post a Comment for "Json.stringify Set Root Element"