js json解析

fxg發表於2024-06-07
//示例1
const jsonString = '{"name":"John", "age":30, "city":"New York"}';
const jsonObject = JSON.parse(jsonString);
console.log(jsonObject["name"]);

//示例2
const sJson='{"infcode":"0","inf_refmsgid":"290002797076070120240606210917","refmsg_time":"20240606210917","respond_time":"20240606210917","err_msg":null,"warn_msg":null,"output":{"sign_time":"20240526143118","sign_no":"NJ3000040000020240526143118"}}';
const jsonOut = JSON.parse(sJson);
console.log(jsonOut["output"]["sign_no"]);

相關文章