-1

I am new to javascript and I have loaded in a json object onto my site using canJS. The json is pretty long (>1000) lines and a fairly complex nested structure. Is there a way to load in the object so I can access the fields and subobjects?

I load in the object to an <li> element then I pass that element into another function. The problem is when it gets to that function I am unable to access the fields. When I look at the developer tools it has the textContext name defined correctly. Should I not be passing the <li>? What object do I pass to my function to manipulate the json object I retrieved using my service?

EDIT: How can I use json.Parse in canJs findAll()?

FYI: Using canjs library, c# 4.0 backend service, json is loaded from mongodb. I have seen that the correct object is returned in chrome developer tools

ford prefect
  • 7,096
  • 11
  • 56
  • 83
  • `JSON.parse(json_string)` gives you a regular javascript object from a string in JSON format ? – adeneo Oct 28 '13 at 18:50
  • So you're receiving a json string and want to work with it as a javascript object? Why are you involving the DOM? Just parse the json (`JSON.parse(str)`) and work with it in javascript. – Jason P Oct 28 '13 at 18:51
  • @JasonP see the edit? I understand that I should not pass the li but what exactly do I pass in? and how do I identify which object should be shown. – ford prefect Oct 28 '13 at 19:13
  • I'm not familiar with CanJS, but... _"I load in the object to an `
  • ` element"_. Why? Why not assign the object to a variable or simply pass the object to your next function?
  • – Jason P Oct 28 '13 at 19:33