[Proto-Scripty] Re: prototype-server side
Thank you Paranav Both cogent responses. I could not find a similar parser in the json-lib. Happily using the json-simple thanks to you. Best of all I can resume coding. On Tue, Mar 16, 2010 at 6:32 PM, chrysanthe m chrysant...@gmail.com wrote: Hello Two questions if I may: 1. Will prototype process javascript associative array into JSON text? 2. I am planning on processing a javascript array into JSON and sending that over an AJAX call as a string. The problem is I cant figure out how to re-hydrate that prototype process JSON string into either a JSON array or a Java object server-side. I am using net.sf.json library. Any insight on either, or both, appreciated. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: prototype-server side
Hi All Actually I did JSONObject.fromObject(); fyi On Wed, Mar 17, 2010 at 11:35 AM, chrysanthe m chrysant...@gmail.comwrote: Thank you Paranav Both cogent responses. I could not find a similar parser in the json-lib. Happily using the json-simple thanks to you. Best of all I can resume coding. On Tue, Mar 16, 2010 at 6:32 PM, chrysanthe m chrysant...@gmail.comwrote: Hello Two questions if I may: 1. Will prototype process javascript associative array into JSON text? 2. I am planning on processing a javascript array into JSON and sending that over an AJAX call as a string. The problem is I cant figure out how to re-hydrate that prototype process JSON string into either a JSON array or a Java object server-side. I am using net.sf.json library. Any insight on either, or both, appreciated. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: prototype-server side
1) The Object.toJSON function should serve your purpose. http://api.prototypejs.org/language/object.html#tojson-class_method e.g. var cat = {name: 'Frisky', age: 2, favoriteQuotes: ['Meow', 'Purr'], likes: {'food': 'Tuna'}} Object.toJSON(cat) {name: Frisky, age: 2, favoriteQuotes: [Meow, Purr], likes: {food: Tuna}} 2) If the only reason you're using JSON-Lib is for this specific purpose, may I suggest using json-simple (http://code.google.com/p/ json-simple/). Its small and functional. String catJSON = {\name\: \Frisky\, \age\: 2, \favoriteQuotes \: [\Meow\, \Purr\], \likes\: {\food\: \Tuna\}}; JSONObject cat = (JSONObject)JSONValue.parse(catJSON); String name = (String)cat.get(name); System.out.println(name); for(Object quote : (JSONArray)cat.get(favoriteQuotes)){ System.out.println(name + says + (String)quote); } If you continue to stick with JSON-Lib, I don't think the parsed representation would be much different from this. On Mar 16, 5:32 pm, chrysanthe m chrysant...@gmail.com wrote: Hello Two questions if I may: 1. Will prototype process javascript associative array into JSON text? 2. I am planning on processing a javascript array into JSON and sending that over an AJAX call as a string. The problem is I cant figure out how to re-hydrate that prototype process JSON string into either a JSON array or a Java object server-side. I am using net.sf.json library. Any insight on either, or both, appreciated. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.