Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is JSON important?

I've only recently heard about JSON (Javascript Object Notation). Can anybody explain why it is considered (by some websites/blogs/etc) to be important? We already have XML, why is JSON better (apart from being 'native to Javascript')?

Edit: Hmm, the main answer theme seems to be 'it is smaller'. However, the fact that it allows data fetching across domains, seems important to me. Or is this in practice not (yet) much used?

like image 209
Rabarberski Avatar asked Apr 29 '09 07:04

Rabarberski


People also ask

Why is JSON so important?

JSON is a wildly successful way of formatting data for several reasons. First, it's native to JavaScript, and it's used inside of JavaScript programs as JSON literals. You can also use JSON with other programming languages, so it's useful for data exchange between heterogeneous systems. Finally, it is human readable.

Is JSON file important?

The most common use of JSON data and files is to read data from a server for a website or web application to display — and change data given the correct permissions. But, that is not the only thing it is used for. Computer applications, programs, mobile apps, and much more all use JSON files.

Why is JSON the best?

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.


1 Answers

XML has several drawbacks:

  • It's heavy!
  • It provides a hierarchical representation of content which is not exactly the same as (but pretty much similar to) Javascript object model.
  • Javascript is available everywhere. Without any external parsers, you can process JSONs directly with JS interpreter.

Clearly it's not meant to replace XML completely. For JS based Web apps, its advantages can be useful.

like image 56
mmx Avatar answered Oct 04 '22 00:10

mmx