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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T22:10:10+00:00 2026-05-28T22:10:10+00:00

My markup where I get the JSON from using $.parseJSON (after replacing single quotes

  • 0

My markup where I get the JSON from using $.parseJSON (after replacing single quotes to double):

<a href="#" data-thumbslide="
  [{'slides':
    [
      { 'path' : 'img/slider-images/jeep_1.jpg' },
      { 'path' : 'img/slider-images/jeep_2.jpg' },
      { 'path' : 'img/slider-images/jeep_3.jpg', 'fullscreen' : 'img/slider-images/jeep_3-fs.jpg' },
      { 'path' : 'img/slider-images/jeep_4.jpg', 'fullscreen' : 'img/slider-images/jeep_4-fs.jpg'}
    ],
  },
  {'info':
    [
      { 'blurb' : 'Lorem ipsum dolor sit amet consquiteur' },
      { 'website' : 'http://www.google.co.uk' },
      { 'credits' : 'Warner bros productions' }
    ]
  }]">
  <div class="title"><h1>Jeep</h1></div>
</a>

I get an object like this: (result from firebug console log)

[Object { slides=[4]}, Object { info=[3]}]

each object looks something like this:

slides object inside JSON object

I can reference the objects like this:

jsonObject[0]['slides'][2].path
jsonObject[1]['info'][0].blurb

However I don’t want to rely on the array order by number (so 0 is ‘slides’ and 1 is ‘info’) but reference them by name instead and not be reliant on the order. I think I can achieve this with a different JSON structure?

  • 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-28T22:10:10+00:00Added an answer on May 28, 2026 at 10:10 pm

    If you omit the outer [] array brackets and a couple of the {} brackets you can make ‘slides’ and ‘info’ properties of the same (non-array) object:

    {
     'slides':
         [
           { 'path' : 'img/slider-images/jeep_1.jpg' },
           { 'path' : 'img/slider-images/jeep_2.jpg' },
           { 'path' : 'img/slider-images/jeep_3.jpg', 'fullscreen' : 'img/slider-images/jeep_3-fs.jpg' },
           { 'path' : 'img/slider-images/jeep_4.jpg', 'fullscreen' : 'img/slider-images/jeep_4-fs.jpg'}
         ],
     'info':
         [
           { 'blurb' : 'Lorem ipsum dolor sit amet consquiteur' },
           { 'website' : 'http://www.google.co.uk' },
           { 'credits' : 'Warner bros productions' }
         ]
    }
    

    And then you can access like this:

    jsonObject['slides'][2].path     // OR jsonObject.slides[2].path
    jsonObject['info'][0].blurb      // OR jsonObject.info[0].blurb
    

    The ‘slides’ property needs to be an array of objects like you have it since each item is of the same type, but I notice that the ‘info’ object is an array containing objects that are all different. If you’ll only have one ‘blurb’, ‘website’, ‘credits’ (or ‘whatever’) within ‘info’ you can restructure that part to remove the nested array and instead make ‘blurb’, etc. properties of a single nested object:

      {'slides':
        [
          { 'path' : 'img/slider-images/jeep_1.jpg' },
          { 'path' : 'img/slider-images/jeep_2.jpg' },
          { 'path' : 'img/slider-images/jeep_3.jpg', 'fullscreen' : 'img/slider-images/jeep_3-fs.jpg' },
          { 'path' : 'img/slider-images/jeep_4.jpg', 'fullscreen' : 'img/slider-images/jeep_4-fs.jpg'}
        ],
      'info': {
          'blurb' : 'Lorem ipsum dolor sit amet consquiteur',
          'website' : 'http://www.google.co.uk',
          'credits' : 'Warner bros productions'
        }
      }
    

    Then you can say:

    jsonObject['info'].blurb
    // or
    jsonObject.info.blurb
    // or
    jsonObject['info']['blurb']
    // or
    jsonObject.info['blurb']
    

    While access to ‘slides’ will still be as above.

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

Sidebar

Related Questions

I am trying to get better about minimizing any unnecessary markup and using optimal
I am using [ http://validator.w3.org/][1] for markup validation and I continue to get errors
Using CFML (ColdFusion Markup Langauge, aka ColdFusion), how can you compare if two single
I'm rendering a drop down list using Html.DropDownListFor() extension. The markup I get is
from the following markup, I want to get options a1, (all), and a. I
How can I get any checkbox from CheckBoxList is selected via jQuery? Markup: <div>
I'm trying to get a site to validate as HTML5 on the W3C Markup
I can't seem to get jQuery to notice the div within the following markup
I'm using django-piston for my REST json api, and I have it all set
Here is the contents of get.json: { id : 1, name : hello }

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.