Solved

what is difference between Javascript and JSON?

Posted on 2014-02-03
3
378 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

830 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