-5
夥計們,DynamoDB調用返回一個JSON對象,我想解析,並獲取密碼哈希場的JavaScript解析JSON字符串
jsonString = JSON.stringify(data)
console.log(jsonString)
輸出:
{"Count":1,"Items":[{"token":{"S":"token"},"uid":{"S":"33c02130-66b5-11e3-bdb0-7d9889f293b5"},"password":{"S":"$2a$10$ervzJ.DWjHOXRtJSugTaWuquI2OvPLyipa4YXecc/2KdQnmhrHxr6"},"username":{"S":"foo"},"plate":{"S":"dinner"},"name":{"S":"Test Name"},"server":{"S":"bar"}}]}
我將如何解析這個字符串,並檢索'密碼'字段? 下面的代碼不起作用:
console.log(jsonString.password)
console.log(jsonString.uid)
下返回未定義:
console.log(data.password);
謝謝!
@PSL可惜就是不工作,我回來 '未定義' – Cmag
'data.Items [0] .password'? – Clive
@ Clive,靠近! {S:'$ 2a $ 10 $ ervzJ.DWjHOXRtJSugTaWuquI2OvPLyipa4YXecc/2KdQnmhrHxr6'} – Cmag