
Twitter Goes JSON-Only With One API - sinzone
http://blog.programmableweb.com/2010/11/10/twitter-goes-json-only-with-one-api-more-to-come/
======
jtchang
Thank god. I hate XML.

XML has its uses but honestly when it comes down to it working with JSON is a
lot easier. When picking a data interchange format you need to consider
indirect advantages as well. JSON is easier to read on a screen, type out, and
overall skim. Skimming XML is a pain.

~~~
thibaut_barrere
The only thing I miss from XML is the ability to comment out something. I
discovered the other day that it wasn't apparently possible.

~~~
davepeck
Formats targeted strictly at machine/machine interchange ultimately get used
for much more. JSON is no exception.

Configuration tends to be the first place that interchange formats are
"abused"; even for such a mild abuse, comments are essential. (Hard-core
abuses, like XML-based programming languages, are another thing entirely. :-)

To deal with JSON's lack of comments, I've considered writing services and
apps that produce JSON, but consume YAML. Here, the interesting qualities of
YAML are (1) it's a superset of JSON, and (2) it supports comments.

~~~
KaeseEs
YAML isn't a _strict_ superset of JSON, although since YAML 1.2 it is very
nearly so; with just a little bit of care you can avoid the edge cases (eg.
you can have hash keys longer than 1024 characters in JSON but not in YAML),
_provided you are cognizant of them_.

------
jhrobert
Impedance mismatch between XML and JavaScript is killing XML.

What's next? HTML? {"head":{"title": "JOHN"},"body:"{"div": "Javascript Object
Hypertext Notation"}}

------
bluedevil2k
Hooray! Let's hope other websites follow their lead and ditch the huge
SOAP/XML overhead and stick with the ease and simplicity of REST/JSON.

~~~
buro9
At Yell we're currently working on our first public API, and only on Friday
did we have the conversation and decided that doing JSON well was far more
important than supporting XML at all.

The decision was a quick one, we just asked the iPhone, Android and web devs
where we should focus, what they wanted most. The answer was unanimously JSON.

------
cloudwalking
Other than smaller bandwidth on each call, what advantages does JSON provide
over XML?

~~~
zdw
Benefits JSON > XML: Less bandwidth for same data, Quick to load, quick to
parse. Very web friendly.

Benefits of XML > JSON: Easy to validate structure and content (via schemas),
and transform content in a language neutral manner (via xslt). Older, thus
supported in more places.

Use what works - JSON is fine for web stuff, XML is better for things that
need strict validation and/or long term data storage.

~~~
andrewvc
I never really got the 'why' behind XML Schemas. Why would you validate a
document with a schema vs actual code? It's just a bigger pain in the ass, and
more limited.

~~~
RodgerTheGreat
If you have multiple applications using a document format, XML schemas are a
good way to make sure they all agree on the semantics of the format. Recall
that XML was originally intended as a means of bridging different environments
and platforms, where code will not necessarily be portable.

~~~
andrewvc
I guess, but even if that's the case, who cares if the message is formatted
right if it's still invalid.

I guess I haven't really worked in a heterogenous environment with a lot of
XML before though, I can see the potential value there, but i'm still
doubtful.

~~~
zdw
The big win for schemas is being able to use them to make assumptions about
input, which simplifies your code.

For example, if you have an RelaxNG schema (which has a great compact syntax)
that says that an element has to have at least one child node and that child
node contains an integer between a certain set of values. Once you have that
schema, you could write code that could read in the XML file and validate it
against the schema in 2 lines, then grab all the child node integers with one
XPath expression.

The data might be junk (heck, I'm not aware of any format that is impervious
to worthless data), but at least it's junk in the right format, and you never
had to mess around with parsing the input.

Need to switch programming environments or languages because you're working on
Unix/Windows/embedded system/mainframe/database/web browser ? The schema can
move with you (or be converted to another schema format that does), and
programming niceties SAX and XPath will often carry over too.

~~~
andrewvc
I can totally see the value now. I haven't used XML in heterogenous
environments much, but I can see the value now.

Thanks for the careful response!

------
runT1ME
_Sigh_

I just implemented my project's API in XML. Time to switch I guess...

~~~
polynomial
Since the 1st line of the article indicates this is the _streaming_ API only,
I will presume that's the one your project is written against.

------
Jach
On XML vs. JSON, I used to hate XML until I started programming in
ActionScript which has a really nice syntax for it (except a few oddities here
and there). I use Enunciate at work ( <http://enunciate.codehaus.org/> ) which
generates XML, JSON, AMF, SOAP/REST endpoints all by itself from base Java
services and classes, which works well too.

Can't say I'm disappointed, back when I did twitter dev I used JSON for
everything, plus it was really easy to interface with our JavaScript client
(duh).

~~~
tomjen3
I haven't used Action script but Scala has really nice support for Xml - it is
properly the only language that allows you to do pattern matching on XML.

~~~
simonw
Scala's creator is on record as regretting the inclusion of XML literals in
the syntax of the language:

[http://www.codecommit.com/blog/scala/working-with-scalas-
xml...](http://www.codecommit.com/blog/scala/working-with-scalas-xml-support)

------
jluxenberg
The article on Programmable Web doesn't add any value to the original press
release: [http://groups.google.com/group/twitter-development-
talk/brow...](http://groups.google.com/group/twitter-development-
talk/browse_thread/thread/6959dc497e4dc546/d8f58c013dc29f4e)

------
asnyder
You'll likely still be able to get results in XML via YQL which offers their
own XML or JSON outputs for most web services.

~~~
simonw
YQL won't work for Twitter's streaming API - it's designed for standard
request/response style APIs.

