Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSON Schema compared with XML Schema and their future

I was looking for JSON schema standards and their corresponding php implementations. Expecting some open source out there and I was surprised, to find only one php implementation. I was about using this technology (JSON) and the schema lib to parse my incoming browser requests.

This natural parse/validate activity seems natural in XML and make me wonder why this is not the case in JSON.

I end up with a doubt situation. Should I pursue my JSON structure data exchange or switch to XML? I first chose JSON for its simplicity and less verbose syntax compared to XML, but if I have to redevelop all existing standard in the world these arguments becomes lighter. I also chose JSON hoping to limit the size of communications between my web server and my mobile apps. Playing with comet apps, XMPP seems to be implemented and used by big names like Google, Facebook, for their real time chat chat text or video based messages.

So the actual questions are:

  1. Is JSON for the poor web server developer that wants to know what happen on its traffic, and focus on over simplicity (do not be mistaken, here, I include myself)?
  2. Does IETF draft for JSON schema is a serious work, since only few implementation exist on the server side (PHP)?
  3. Am I missing something, or maybe, the best communication pattern is to send data in xml to the server and expect a json response (many json schema implementation exist in javascript)?
  4. Or did I only faced the actual proof, that this concern has not been well served by the developer community because web developer using JSON do not test deeply their incoming request data?

Please help me understand, I am missing some experience here?

like image 946
Alain Avatar asked Mar 24 '12 18:03

Alain


People also ask

What is a benefit of JSON compared to XML?

JSON is faster because it is designed specifically for data interchange. JSON encoding is terse, which requires less bytes for transit. JSON parsers are less complex, which requires less processing time and memory overhead. XML is slower, because it is designed for a lot more than just data interchange.

What is the difference between JSON and XML?

JSON (JavaScript Object Notation) is a lightweight data-interchange format and it completely language independent. It is based on the JavaScript programming language and easy to understand and generate. XML (Extensible markup language) was designed to carry data, not to display data.

What is the purpose of schema in XML and JSON?

The purpose of an XML Schema is to define the legal building blocks of an XML document: the elements and attributes that can appear in a document. the number of (and order of) child elements. data types for elements and attributes.

Is JSON replacing XML?

Yes, JSON is rapidly replacing XML for RPC-style communication: not just AJAX from browser, but server to server.


1 Answers

This natural parse/validate activity seems natural in XML and make me wonder why this is not the case in JSON.

Remember what made JSON famous: web applications with a very rich user interface written in JavaScript. JSON was perfect for that because data from the server mapped directly on JavaScript objects; hit a GET URL with Ajax and get back an object, no need for parsing or anything else.

Those rich interfaces made JavaScript a very popular language and JSON obviously rode along and it's popularity made it become the best candidate to overthrow "the angle bracket".

But XML has a long history behind it. It's a mature technology with lots of accompanying specifications. JSON is just catching up to those.

Although the draft specification expired in May 2011, the JSON Schema supporters think they have reached a pretty close to final version of the spec. So who knows what the future has in hold for JSON Schema.

I was surprised, to find only one php implementation [...] Does IETF draft for JSON schema is a serious work, since only few implementation exist on the server side (PHP) ?

Does this PHP implementation validate JSON as per the last version of the JSON Schema draft? If yes, is there a need for other implementations? Do you need lots of implementations to certify a specification is serious? That's just as saying that XSLT 2.0 is not serious because Microsoft didn't bother to implement it.

As for your last question, incoming data needs to be validated. You don't take a user request and throw it to the server and "hope it sticks". You validate it; and JSON Schema is not the only way to validate JSON data, so don't assume that web developers using JSON do not deeply test their incoming request data.

In conclusion, what I'm trying to say is that JSON can't fully replace XML, or the other way around. So use each technology where appropriate.

like image 129
Bogdan Avatar answered Sep 24 '22 00:09

Bogdan