Solved

what is difference between Javascript and JSON?

Posted on 2014-02-03
3
377 Views
Last Modified: 2014-02-05
Can anyone please tell me what is difference between Javascript and JSON?
What are the benefits of JSON over Javascript? When should I be using one over the other?
0
Comment
Question by:RajG1978
3 Comments
 
LVL 29

Accepted Solution

by:
Paul Jackson earned 250 total points
ID: 39831499
JSON is a language independent data interchange format most commonly used as an alternative to XML.

While JSON objects are based on the Javascript object literal they are not the same.

to summarize JSON is a data interchange format, javascript is most commonly used a client-side scripting language although it can also be used on the server-side.

http://msdn.microsoft.com/en-us/library/bb299886.aspx
0
 
LVL 11

Assisted Solution

by:MajorBigDeal
MajorBigDeal earned 250 total points
ID: 39831501
Javascript is an implementation of a programming language (EcmaScript)

JSON is format for exchanging data. It is based on Javascript but it's purpose is as a format for exchanging data not to write programs.

So Javascript is in the programming language category, like C# for example.  JSON is in the data-exchange format category, like XML for example.
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39831949
Are you asking about a javascript array vs json?  I think they get confused a lot.
array
var beer=["Dunkel-weizens","Porters","Stout"];

Open in new window

vs json
{
    "beer": [
        {
            "style": "Dunkel-weizens"
        },
        {
            "style": "Porters"
        },
        {
            "style": "Stout"
        }
    ]
}

Open in new window


With an array you select items by their index 0,1,2.  With json, you can use the names beer or style.  

Do you have a particular use case?
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Learn by example how to specify CSS selectors for Selenium WebDriver test automation software.
Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question