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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:04:31+00:00 2026-05-24T04:04:31+00:00

If I am to have this external json file: { http://example.org/about : { http://purl.org/dc/elements/1.1/title

  • 0

If I am to have this external json file:

{
"http://example.org/about" :
    {
        "http://purl.org/dc/elements/1.1/title" : [{"value" : "annas homepage" , "type" : "literal"}]
    }
}

and this external jquery script that fetches title of the book inside json file:

var a = 'http://example.org/about'
var b = 'http://purl.org/dc/elements/1.1/title'

$(document).ready(function() {
  $("#trigger").click(function(event) {
    $.getJSON('rdfjson.json', function(json) {
      $('#meta').html('Title: ' + json.a.b[0].value);
    });
  });
});

and this HTML code:

<p>Click on the button to fetch data from json structure:</p>
<div id="meta">
This text will be overwritten.
</div>
<input type="button" id="trigger" value="Load Data" />

Why wouldn’t it work? When I use normal strings inside json document and script, it works OK.

Also, I don’t understand how could I iterate through the whole json file if it is, for example, more complex or elements have long vectors containing data etc etc..

Thanks a lot!

  • 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-24T04:04:32+00:00Added an answer on May 24, 2026 at 4:04 am

    Because you’re looking for an object member named a, rather than an object member whose name is the value stored in the variable “a”.

    Instead of using “dot notation“, use “square bracket notation“

    $('#meta').html('Title: ' + json[a][b][0].value);
    

    For more information, see here: http://www.dev-archive.net/articles/js-dot-notation/

    Edit:

    If the JSON structure varies like so:

    1. Version One:

      {
          "http://example.org/about" :
          {
              "http://purl.org/dc/elements/1.1/title" : [{"value" : "annas homepage" , "type" : "literal"}]
          }
      }
      
    2. Version Two:

      {
          "http://somewhereelse.com/something" :
          {
              "http://anotherplace.org/dc/blah-blah-blah/title" : [{"value" : "annas homepage" , "type" : "literal"}]
          }
      }
      

    e.g. there is always one object, which has one member which has one member

    … and you need to target it:

    $.getJSON('rdfjson.json', function(obj) {
      for (var x in obj) {
          if (obj.hasOwnProperty(x)) {
             var obj2 = obj[x];
    
             for (var x in obj2) {
                if (obj2.hasOwnProperty(x)) {
                    $('#meta').html('Title: ' + obj2[x][0].value);
                }
             }
          }
      }
    });
    

    You can of course add conditionals within the for loops if you know a little bit more information about the path you need to traverse:

    $.getJSON('rdfjson.json', function(obj) {
      for (var x in obj) {
          // if you know you're looking for a key that begins with "http://"
          if (obj.hasOwnProperty(x) && x.indexOf("http://") === 0) { 
             var obj2 = obj[x];
    
             for (var x in obj2) {
                // Check that the value is an array of at least length 1, and whose 1st value has the property "value".
                if (obj2.hasOwnProperty(x) && obj2[x] instanceof Array && obj2[x].length > 0 && obj2[x][0].value) { 
                    $('#meta').html('Title: ' + obj2[x][0].value);
                }
             }
          }
      }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an external JSON file that has this in it: { Home: [
I have this code: $.getJSON('http://www.reapp.se/cmesapp/cmes.json?callback=?', function(data){ alert(disco); }).error(function() {alert(fail!;}); Which is sending out an
I have the following JSON string coming from external input source: {value: "82363549923gnyh49c9djl239pjm01223", id:
I have an external JSON file (data.json) and would like to get data from
I have the following JSON in my view (simplified for this example): video =
I have this external module of my system and I thought to integrate it
i have this simple type from an external webservice: <xsd:element name=card_number maxOccurs=1 minOccurs=1> <xsd:simpleType>
I use an externel javascript file and i have this, function getdropdownvalue() { alert($(#<%=DLState.ClientID%>));
We have two systems: external and internal, which are sharing information in JSON format
I have this bit of javascript: var jsonString = some string of json; $.post('proxy.php',

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.