开发者

Which json library should I use to pass my array of objects (javascript) to the server (java) and vice versa?

开发者 https://www.devze.com 2023-01-29 03:57 出处:网络
I have an array of objects in javascript and I know that I need to use json to pass it to server, but I don\'t know which library I should use. I found 开发者_如何转开发inthis post, that I have to use

I have an array of objects in javascript and I know that I need to use json to pass it to server, but I don't know which library I should use. I found 开发者_如何转开发in this post, that I have to use JSON.stringify() function; , but there's also a comment that says that JSON.stringify is not a standard function and I should use json2.js instead. What I'd like to know is :

  1. Is there any pre-installed Json library in javascript?

  2. Which is the best Json library I can use in javascript as well as in java.

  3. And... if it´s not too much to ask... where can I get those libraries

thanks beforehand


  1. There is a JSON property in the global object for browsers using the ECMAScript v5 specification (Dec 09).
  2. If it's in both Java and JavaScript then it's not the same library... Personally, I usually use Jackson in Java and ExtJS in Javascript.
  3. Here and here. A much more lightweight js implementation can be found here.


See http://en.wikipedia.org/wiki/JavaScript_Object_Notation#Using_JSON_in_Ajax and http://en.wikipedia.org/wiki/JavaScript_Object_Notation#Native_JSON.

JSON is supported natively in modern browsers (and in older browsers through eval(), but with possible security and perf implications). http://json.org/ provides a list of JSON libraries for older browsers where native JSON is not supported and the use of eval() is not a good idea.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号