var str={"act":"{\"act\":\"inittemplate\",\"titleid\":\"2\"}","newName":null,"obj":[{"titleid":2,"titlename":"医疗产品","tsid":1,"tsname":"自动注射器","tssid":1,"tssimg":"\/cy\/images\/byz01.jpg","tssname":"比杨单通道注射泵BYZ-810"},{"titleid":2,"titlename":"医疗产品","tsid":1,"tsname":"自动注射器","tssid":2,"tssimg":"\/cy\/images\/byz01.jpg","tssname":"史密斯输液器"},{"titleid":2,"titlename":"医疗产品","tsid":2,"tsname":"血压器","tssid":3,"tssimg":"\/cy\/images\/byz01.jpg","tssname":"比杨单通道注射泵BYZ-810"},{"titleid":2,"titlename":"医疗产品","tsid":2,"tsname":"血压器","tssid":4,"tssimg":"\/cy\/images\/byz01.jpg","tssname":"比杨单通道注射泵BYZ-810"},{"titleid":2,"titlename":"医疗产品","tsid":3,"tsname":"血糖仪","tssid":5,"tssimg":"\/cy\/images\/byz01.jpg","tssname":"比杨单通道注射泵BYZ-810"},{"titleid":2,"titlename":"医疗产品","tsid":3,"tsname":"血糖仪","tssid":6,"tssimg":"\/cy\/images\/byz01.jpg","tssname":"比杨单通道注射泵BYZ-810"}]}
上面的是json格式数据
var data2 = eval("(" + str + ")");
var jsonstring2 = data2.obj;
var tempids = "";
for (i in jsonstring2) {
jsonstring2[i].tsname//这个地方等得到值,
}
需求是: 要把json解析成
"tsid":2 "tsname":"血压器"
"tssid":4 "tssname":"比杨单通道注射泵BYZ-810"
"tssid":3 "tssname":"比杨单通道注射泵BYZ-810"
"tsid":1,"tsname":"自动注射“
"tssid":2 "tssname":"史密斯输液器"
"tssid":1 "tssname":"比杨单通道注射泵BYZ-810"