0

i need a help .i have a JSON file that i want to parse and get some value from it.

i have json in following format:

enter code here

{
"node":{
"default":{
"display Name": "abc"
    }
  }
}

i want to parse display name . right now only object coming.

shilovk
  • 11,718
  • 17
  • 75
  • 74
Kunal
  • 43
  • 9
  • How are you accessing it? This is possibly a duplicate of this question: https://stackoverflow.com/questions/10311361/accessing-json-object-keys-having-spaces – SevenEleven Aug 05 '17 at 07:40
  • post your code snippet where you are parsing this , also, are you using typescript? – TruckDriver Aug 05 '17 at 08:37
  • rephrase your post to make more sense – Aravind Aug 05 '17 at 09:18
  • @Timothy yes m using typescript in my html file m parsing like this,i know there are some problem here
    settings.badgeShowLimit-1"> {{item.label}}
    please let me know how should i parse it
    – Kunal Aug 05 '17 at 09:51
  • @Timothy : could you please tell me the equivalent code for multiple label for below code: item.label["Application"]._default["displayName"] (it printed the result) – Kunal Aug 05 '17 at 10:12
  • How does the code look like? Show us the http request and component code. No one can really help based on this little information. Is that JSON all you get, or is this just part of response? – AT82 Aug 05 '17 at 14:22

2 Answers2

0

U can get the object and use "object.default.displayName" to display the name

Mr.Gaja
  • 173
  • 2
  • 3
  • 12
  • i tried it.but it is throwing a error that display name is undefined property – Kunal Aug 05 '17 at 08:16
  • remove the spce in " display Name" in ur json file.. change it to displayName or display_Name something like that – Mr.Gaja Aug 05 '17 at 08:48
0

Run this code snippet in console. You will get display name.

var data = {
    "node":{
    "default":{
    "display Name": "abc"
        }
      }
    }

    console.log("Display Name :: " + data.node.default["display Name"] );
Rohan Fating
  • 2,135
  • 15
  • 24
  • Not working Cannot read property 'default' of undefined this error coming. – Kunal Aug 05 '17 at 11:14
  • Did you tried above snipped in browser console? it is working for me. Ideally this should work, please check your json data. You can also do ::::: data["node"]["default"]["display Name"] – Rohan Fating Aug 05 '17 at 15:49