json vs xml

what are differences between json and xml. what are advantages, disadvantages of each

I read like below
JSON uses typed objects. All XML values are typeless strings and must be parsed at runtime
what it mean by typed object and typeless strings and runtime parsing

please advise
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Both are text based human readable formats. XML was originally designed for interoperability so that company A could share information with company B. When used this way the industry would decide what a "Customer" object was then so long as company A and B used this definition then they could share data. DTD, schemas and namespaces are used to enforce this. But this only really took off in the B2B world. In the B2C world where the same company is both the producer and consumer of the data (a web page posting a request to a web service and then consuming the response) JSON works fine, is much less verbose and maps to Javascript without manual parsing.
ste5anSenior DeveloperCommented:
You should pick your lectures more carefully..

- JSON is text. XML is text.
- JSON is an object representation of a JavaScript object. XML is language agnostic data representation.
- JSON only has string and number as data types (Boolean, NULL also). XML does not contain data types. But DTD and XML Schema can define much more data types for a XML file than JSON.
- JSON must be parsed at runtime. XML must be parsed at runtime.

what are advantages, disadvantages of each
This solely depends on the use-case.

what it mean by typed object and typeless strings and runtime parsing
Parsing, compile time, run time. Look that up.. basic concepts of how program code gets executed.

Objects are instances of classes. Or Objects are instances prototypes. The later is the case in JS. Typed objects have runtime information about their type. Thus they can be distinguished. Otherwise they needed to be compared by enumerating their interface, which allows duck typing.
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

David FavorLinux/LXD/WordPress/Hosting SavantCommented:
Reading the question my first though was, depends heavily on what you're trying to accomplish.

Describe your application in detail + likely you'll receive some great suggestions.
MurpheyApplication ConsultantCommented:
Hi gudii9,

They are all right.
To my opinion they both serve the same goal, but most of the time the XML version is the professional solution (hey..just an opinion)

You stated "All XML values are typeless strings and must be parsed at runtime"
Correct, but normally you define a XML in an XSD and that is a format that goes far beyond the Json possibilities.
Where JSON needs a document to explain the communication partner what to deliver, the XSD is importable as template, and  don't need much explanation (if right defined)

Using Webservices, the XSD is part of the WSDL and no extensive template documentation is required.
JSON entities is lighter than XML, JSON objects are easier to use with Javascript
XML is strongest when you need to validate XML entities with XSD and/or apply transformation using XSLT (do a PDF, MS Word, a picture,...)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ste5anSenior DeveloperCommented:
Just again: JSON represents an object. XML is only data.
JSON objects are DTOs, so only data too. From the json.org "JSON (JavaScript Object Notation) is a lightweight data-interchange format"

So json object are no more objects than their XML counterpart. The difference between the two is simply syntax. You can even write some XSLT to transform the XML to json they are that similar.

Json is used very widely in restful services whereas XML tends to be used in traditional RPC web services.

If you are free to choose, I'd go with json as it is now more widely used and the tooling is maturing. It is more easily consumed by browsers and has a lower bandwidth requirement.

Technically, anything you can do with one can be done with the other. In some circumstances one will be easier than the other - it all depends on who your consumer is.
MurpheyApplication ConsultantCommented:
Sorry ste5an,

Json is just formatted data.
XML is a markup language.

I even use a XML script-language in our ESB to create Webservices.
MurpheyApplication ConsultantCommented:
I propose to divide the points evenly
MurpheyApplication ConsultantCommented:
There is not a right or wrong answer on a "what are differences" question
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.