javascript - SQL Join query successfully converts into JSON but how do I interact with it? -
i have sql join on 2 tables below:
_____persons_____ name: "joe" age: 28 job_id: 0 _____jobs_____ job_id: 0 job_title: "farmer" "select * persons inner join jobs on persons.job_id = jobs.job_id" then convert sql output json c# system.web.script.serialization... output of json object:
var personal_report = [{"name":"joe", "age":28, "persons.job_id":0, "jobs.job_id":0, "job_title:"farmer"}] this great, when go access json object, cannot use "job_id". perhaps syntax off?
personal_report[0].name // outputs "joe" personal_report[0].job_title // outputs "farmer" personal_report[0].job_id // error personal_report[0].persons.job_id // error personal_report[0].jobs.job_id // error how can access attribute? many thanks!
keys in json contains . characters , therefore cannot access directly. can use [] notation access properties string this:
personal_report[0]['persons.job_id']; // 0 personal_report[0]['jobs.job_id']; // 0
Comments
Post a Comment