Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 176775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T13:56:15+00:00 2026-05-11T13:56:15+00:00

In most JSON serializers/deserializers, the key part in a javascript dictionary/hash array is written

  • 0

In most JSON serializers/deserializers, the ‘key’ part in a javascript dictionary/hash array is written as a string.

What is the benefit of using a string as the key as opposed to just typing the intended name in?

For example, say I define two objects k1 and k2 like so:

var k1 = { a: 1, b: 2, c: 3 };          // define name normally var k2 = { 'a': 1, 'b': 2, 'c': 3 };    // define name with a string 

And I then ran the following tests:

alert(k1 == k2);                   // false (of course)  alert(k1.a == k2.a);               // true alert(k1['b'] == k2['b']);         // true  alert(uneval(k1));                 // returns the k1 object literal notation. alert(uneval(k2));                 // returns the same string as above line.  alert(uneval(k1) == uneval(k2));   // true 

So what’s the point of having the keys be in double-quotation marks (a string) as in the way k2 was defined instead of just typing the key names in as in the way k1 was defined?


I just saw this over at Ajaxian pointing to Aaron Boodman’s blog entry:

chromium.tabs.createTab({  'url': 'http://www.google.com/',  'selected': true,  'tabIndex': 3 }); 

Since he also use camel case for tabIndex, I don’t see any point in using a string at all.

Why not:

chromium.tabs.createTab({  url: 'http://www.google.com/',  selected: true,  tabIndex: 3 }); 

Why would a JS ninja follows the convention of turning url, selected and tabIndex into a string?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T13:56:15+00:00Added an answer on May 11, 2026 at 1:56 pm

    Because JSON is a subset of the actual JavaScript literal syntax. For simplicity in implementing JSON parsers, double quotes are always required around strings, and as keys in JSON are strings, they are required there.

    Not all legal JavaScript is legal JSON. While you can define object literals in JavaScript without the quotes, if you want interoperable JSON, you’re going to need to put them in.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 118k
  • Answers 119k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I'd use a 'Try' prefix and maybe have it return… May 11, 2026 at 11:41 pm
  • Editorial Team
    Editorial Team added an answer Nope. Environment variable changes on Windows only take effect for… May 11, 2026 at 11:41 pm
  • Editorial Team
    Editorial Team added an answer No, I don't believe there's any way of doing this.… May 11, 2026 at 11:41 pm

Related Questions

For context, we are storing most of our data as JSON strings. This works
I am trying to use JSON to populate a div, so I basically run
What is a good way to render data produced by a Java process in
Trying to comply with StackOverflow's suggestion of asking a question, not creating a discussion,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.