Timeline for Why need to use JSON in php and AJAX
Current License: CC BY-SA 2.5
6 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Oct 27, 2011 at 0:54 | vote | accept | Barry | ||
| Oct 27, 2011 at 0:54 | |||||
| Feb 3, 2011 at 8:55 | comment | added | user166390 | (Although I suppose <json>{'1' => ['a', 2, 3], '2' => "string"}</json> is always an option grin) | |
| Feb 3, 2011 at 8:49 | comment | added | user166390 | Terseness is a human-comfort (I like it). Also XML is fairly compressible and bandwidth isn't getting any less... andyway, the {'1' => ['a', 2, 3], '2' => "string"} would be <o><a key="1"><s>a</s><n>2</n><n>3</n></a><s key="2">string</s></o>. Basically the element is the type and if it represents an object's prop value has the "key" attribute contained within it (null and undefined are also represented as unique elements). First choice here would have been to use JSON -- I'm mostly playing the devil advocate -- but that wasn't an option as XML was required through the stack :-/ | |
| Feb 3, 2011 at 6:34 | comment | added | deceze♦ | @pst Sure. But the XML format is much more verbose and hence has a lot more overhead. The only advantage it has is a more complex format, e.g. allowing attributes on values, but that's often unnecessary for AJAX requests. Do you have a concrete example of "JXON"? | |
| Feb 3, 2011 at 6:06 | comment | added | user166390 | But one could just as easily use DecodeXML(EncodeXML(array)) -- the method names are made up, but the same applies. The only "requirement" as far as use of transport is that both sides can process the data in a defined matter. Internally I use an "JXON" format which is JSON mapped to XML (some of the libraries deal with XML but not JSON :-/) Don't get me wrong, for most cases I'd rather look at JSON in a response I'm trying to debug ^^ | |
| Feb 3, 2011 at 1:41 | history | answered | deceze♦ | CC BY-SA 2.5 |