javascript - need to access second degree json field but code is only set up for first -
i'm trying pass function identifier access field "yrhiprice" in (very simplified) json quote object:
quote: { "last": "49.65", "fundamentaldata": { "yrhiprice": "49.77000" } }
the function i'm passing to, can't edit, accesses these fields based on data-field set table cell:
<td data-field="last"></td>
and (very simplified) function, can't edit, takes whatever's in data-field attribute , uses key access fields in object
var name = $elt.data('field'); var value = (quote[name]) ? (quote[name]) : '---'; $elt.text(value);
so, rather ridiculous question: there way access "yrhiprice" field, though it's going drop first set of brackets?
i've tried "fundamentaldata["yrhiprice"]", "fundamentaldata.yrhiprice", , "fundamentaldata][yrhiprice" no luck.
thanks much!
if can't edit function , fundamentaldata.yrhiprice
doesn't work, flatten object the yrhiprice
property copied level. work if property names need re-create unique, in case, you'd have take care prefix or suffix properties create them unique.
so if have quote
object, you:
myquote.fundamentaldata_yrhiprice = myquote.fundamentaldata.yrhiprice;
and then:
<td data-field="fundamentaldata_yrhiprice">
javascript json
No comments:
Post a Comment