javascript - How to select a key: value pair in string format used in a JSON object? -
i want select length, it's in string form. along lines of attribs.length, returned nothing.
attribs: { "length": ""4"", "nightride": "null" }
i've tried splitting , rejoining either way don't want. i've tried attribs[length] , attribs["length"] no avail.
here major chunk from:
{ places: [ { city: "boise", state: "idaho", country: "united states", name: "elk meadows", parent_id: null, unique_id: 1637, directions: ""from boise's north end (at intersection of hill , bogus basin roads), travel north bogus basin road 16.5 miles.the pavement ends @ lower (main)parking lot near bogus creek lodge. proceed on boise ridge rd. sandy surface turns pavement leavesthe main ridge rd.and splitsright, through series of switch backs pioneer lodge milage starts here", lat: 43.764, lon: -116.10324, description: null, date_created: null, children: [ ], activities: [{ name: "elk meadows", unique_id: "1-118", place_id: 1637, activity_type_id: 5, activity_type_name: "mountain biking", url: "http://www.singletracks.com/item.php?c=1&i=118", attribs: { "length": ""4"", "nightride": "null" }, description: "ride east behind pioneer lodge past tennis courts on left. double track becomes more defined", length: 4, activity_type: { created_at: "2012-08-15t16:12:35z", id: 5, name: "mountain biking", updated_at: "2012-08-15t16:12:35z" }, thumbnail: "http://images.singletracks.com/2010/11/elk-meadows-on-the-ranier-0.jpg", rank: null, rating: 3 } ] },
and angular attempt data:
{{ result.activities[0].attribs["length"] }}
if attribs actual javascript object , want numeric value of attribs.length
var x = parsefloat(attribs.length.replace(/"/g,''));
Comments
Post a Comment