Hey guys, I wanna know 2 things first if possible:

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

I can`t work anymore with javascript arrays, it really sucks...

Hope you guys give me a light :)

link|improve this question

75% accept rate
1  
Why "can`t [you] work anymore with javascript array"? JSON is just the array and object literal syntax of Javascript. If you like JSON syntax you should feel right at home when using arrays and objects in Javascipt. – Alexandre Jasmin Nov 8 '10 at 0:30
feedback

2 Answers

up vote 4 down vote accepted

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.

link|improve this answer
feedback

Take some time and read this article: There's no such thing as a "JSON Object"

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.