Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
129
rated 0 times [  132] [ 3]  / answers: 1 / hits: 114092  / 14 Years ago, mon, november 8, 2010, 12:00:00

I was wondering how can I create a JSON (JS) object and then clone it.


More From » jquery

 Answers
20

How to create a JSON object in javascript/jquery?




There is nothing like a JSON object. JSON stands for JavaScript Object Notation and is basically a string that encodes information similar to JavaScript's object literals.



You can however create such an encoding (which would result in a string) with JSON.stringify(object), see JSON in JavaScript. You could also create such a string manually, but it is very error prone and I don't recommend it.




How do I clone a JSON object in javascript/jquery?




As it is just a string:



var jsonString2 = jsonString;



I can`t work anymore with javascript arrays




JSON is a format to exchange data, it is not a data structure you can use in an application.






Maybe you want to read more about JSON, objects in JS and arrays in JS.


[#95045] Thursday, November 4, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
cruzjenseny

Total Points: 409
Total Questions: 93
Total Answers: 106

Location: Lithuania
Member since Fri, Sep 4, 2020
4 Years ago
;