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 7406967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:38:15+00:00 2026-05-29T05:38:15+00:00

I always get confused on how to properly format json. I think its because

  • 0

I always get confused on how to properly format json. I think its because I need to walk away and take a breather.

I have a have a ecommerce system and I have a script that I want to display category information via json. Will displaying it this way:

{
    "cat_name": "All Items",
    "cat_desc": "<div><img src=\"item.gif\" /></div>",
    "cat_desc2": "",
    "cat_id": "756",
    "cat_father_id": "0",
    "cat_image": "",
    "per_ship": "0.00",
    "item_ship": "0.00",
    "item_int_ship": 0,
    "per_int_ship": "0.00",
    "noProducts": "45",
    "disp_order": "3",
    "cat_img_folder": ""
}

Would I be able to reference these items after being initlized to an object like so:

obj.cat_name
obj.cat_id
  • 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. Editorial Team
    Editorial Team
    2026-05-29T05:38:15+00:00Added an answer on May 29, 2026 at 5:38 am

    That’s properly formated, if your service returns that information you could do the following

    $.getJSON('YOURSERVICEURL', function(data) {
    
      $.each(data, function(key, val) {
        console.log('KEY: ', key, ' VALUE', val );
      });
    
    });
    

    where key will be the property and val the value when you access it (in the fashion data[key] === value, or, data.key === value).
    So, yes, if data has the key that you’re looking for (in your case cat_name cat_id, you can get them.

    One thing to have in mind is that Numbers doesn’t need to be between "", if you want them to be numbers when you access them via object properties

    Also, if you ever need to know if you’re formatting your json correctly you could take a look at this link

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

Sidebar

Related Questions

OK, I always get confused about this. Let's say I have this code. Public
I always get confused between the static and dynamic scoping and hence need someone
I get always confused when I have to give a new name for a
I always get confused when I am about to use a bit map to
I always get confused with licenses, I'm reading up again, but I'm sure someone
While designing the class, I always get confused what to put in Constructor and
I always get confused. Would someone explain what Reentrant means in different contexts? And
Hey guys, I always get confused by this so it's not exactly my strong
One thing that's always confused me is how a BackgroundWorker seems to have thread-safe
I'm confused by my rake routes output. For an example (trimmed): profil GET /profil/:id(.:format)

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.