[jQuery] Re: Array to JSON?

2009-06-23 Thread Ricardo
I know, I meant it won't handle actual arrays like [1,2,3]. Wasn't needed at the time, probably not too difficult to implement. On Jun 22, 9:24 pm, Josh Powell seas...@gmail.com wrote: That's okay, javascript doesn't have associative arrays, only arrays with object properties. On Jun 22,

[jQuery] Re: Array to JSON?

2009-06-23 Thread cs
Why not make each field that has a nested key-value pair an object instead? In short, any array with a key but without a value is an object since your value is just an array of elements. What language is in charge of your back-end? And how is it handling the inputs your pass it? This is what

[jQuery] Re: Array to JSON?

2009-06-23 Thread Nic Hubbard
Well, right now I am sending JSON to my php script which then uses json_decode() to make them into vars. But, I am wondering, is sending JSON the best way? Or should I just send the data as a normal query string, rather than JSON? Which is best? On Jun 22, 5:13 pm, cs

[jQuery] Re: Array to JSON?

2009-06-23 Thread Ricardo
Sending JSON to the server adds a layer of complexity to both sides. If it has no benefits (I don't see any), then yes, you're better off keeping it simple and using a query string and $_POST instead. jQuery handles object to query string conversion automatically: $.post('cheese.php', { cat: 1,

[jQuery] Re: Array to JSON?

2009-06-22 Thread diogobaeder
Hmmm... why would one use this plugin if we have Douglas Crockford's json2.org, which is the original JSON library from the same creator of the concept JSON? And why load more modules into the main jQuery object, making it heavier, if we don't use DOM element wrappers in the plugin, only

[jQuery] Re: Array to JSON?

2009-06-22 Thread Ricardo
Usually you'll send out parameters in query strings, only receive data in JSON, which is what jQuery is equipped to do. If you don't want the weight of a plugin you could use something like this: function toJSON(obj){ var json = '({'; $.each(obj, function(k,v){ var q = typeof v == 'string' ?

[jQuery] Re: Array to JSON?

2009-06-22 Thread Ricardo
before someone complains: that function won't handle arrays (only objects) On Jun 22, 6:39 pm, Ricardo ricardob...@gmail.com wrote: Usually you'll send out parameters in query strings, only receive data in JSON, which is what jQuery is equipped to do. If you don't want the weight of a plugin

[jQuery] Re: Array to JSON?

2009-06-22 Thread Nic Hubbard
Yeah, I am not too hot on using a plugin for this. I had hoped there was just a quick function that I could pass in an array and return JSON. On Jun 22, 8:28 am, diogobaeder diogobae...@gmail.com wrote: Hmmm... why would one use this plugin if we have Douglas Crockford's json2.org, which is

[jQuery] Re: Array to JSON?

2009-06-22 Thread Josh Powell
That's okay, javascript doesn't have associative arrays, only arrays with object properties. On Jun 22, 2:45 pm, Ricardo ricardob...@gmail.com wrote: before someone complains: that function won't handle arrays (only objects) On Jun 22, 6:39 pm, Ricardo ricardob...@gmail.com wrote: Usually

[jQuery] Re: Array to JSON?

2009-06-21 Thread kranthi
are u looking for http://www.google.co.in/search?q=jquery+json+plugin ?