0

I am having troubles to get specific keys from nested JSON in javascript.

I want to create HTML table where
columns would be:
id, Card Trader, MKM Low, MKM Trend..... those level keys

and rows would be:
"006bd15a-3949-51a7-9c11-06142f3bcc41",
"006bd15a-3949-51a7-9c11-06142f3bcc41_f"
...those level keys

and for each particular row I would like to assign corresponding number to given columns.

Example JSON:

{ "meta": 
  { "date"     : "2023-03-05T10:59:32.186618976Z"
  , "version"  : "1"
  , "base_url" : "http://www.mtgban.com/go/"
  } 
, "retail": 
  { "006bd15a-3949-51a7-9c11-06142f3bcc41": 
    { "Card Trader"    : { "regular": 12.907334677847363 } 
    , "MKM Low"        : { "regular": 12.090011676042883 } 
    , "MKM Trend"      : { "regular": 12.80118883345717  } 
    , "TCG Direct"     : { "regular": 19.55 } 
    , "TCG Direct Low" : { "regular": 19.55 } 
    , "TCG Low"        : { "regular": 14.94 } 
    , "TCG Market"     : { "regular": 15.62 } 
    , "TCG Player"     : { "regular": 17.74 } 
    } 
  , "006bd15a-3949-51a7-9c11-06142f3bcc41_f": 
    { "Card Trader"    : { "foil": 14.499522343700244 } 
    , "MKM Low"        : { "foil": 14.319074408236917 } 
    , "MKM Trend"      : { "foil": 14.096168135017514 } 
    , "SCG"            : { "foil": 15.99 } 
    , "TCG Direct"     : { "foil": 17.04 } 
    , "TCG Direct Low" : { "foil": 17.04 } 
    , "TCG Low"        : { "foil": 16    } 
    , "TCG Market"     : { "foil": 16.96 } 
    , "TCG Player"     : { "foil": 17.06 } 
    } 
  } 
} 

data[0].retail ... brings me to unique ID's but I am unable to push each of them to unique rows.

and since i am unable to universaly tag those ID's I don't know how to refer to another level. I would expect something like this:

data[0].retail (missingpiece).['Card Trader'].regular

Mister Jojo
  • 20,093
  • 6
  • 21
  • 40
  • 3
    You should show the code you're using to retrieve the values, but I think your missing piece is `"006bd15a-3949-51a7-9c11-06142f3bcc41"`, et al. `data[0].retail["006bd15a-3949-51a7-9c11-06142f3bcc41"].['Card Trader'].regular` . BTW, this is an Object, not JSON; JSON is a string. JSON can be parsed into an Object. – mykaf Mar 08 '23 at 14:05

0 Answers0