Json select a specific item out for editing with javascript

Posted by minus4 on Stack Overflow See other posts from Stack Overflow or by minus4
Published on 2010-04-26T13:04:50Z Indexed on 2010/04/26 13:13 UTC
Read the original article Hit count: 385

Filed under:
|

I have the following JSon:

{"DPI":"66.8213457076566",
"width":"563.341067",
"editable":"True",
"pricecat":"6",
"numpages":"2",
"height":"400",
"page":[{"filename":"999_9_1.jpg",
 "line":[{"test":"test 1",lineid:22},
 {"test":"test 2",lineid:22},
 {"test":"test 3",lineid:22},
 {"test":"test 4",lineid:22},
 {"test":"blank",lineid:22}]},
 {"filename":"999_9_2.jpg",
 "line":[]}]}#

i can do most things with lines like
measurements.page[0].line[0].lineid;

but what i am really stuck with is when i want to edit a specific line but i only have lineid available and not the line number in the array, for example:

measurements.page[0].line[0].test = "new changed value";

however i dod not know the line number I.E  0 line[0]

is there a way for me to get the line number of a line that has a lineid value of say 22 ????

and all within javascript

thanks

© Stack Overflow or respective owner

Related posts about JSON

Related posts about JavaScript