-2

如何使用 webload javascript 从 json 中检索值

Message: keys value is : {"_Success": 1, "Criteria": "1234", "SearchAndSelect":  [ {"DateOfBirth": 
"15/02/1962","EmpNo": "123456","LastName": "John", "FirstName": "Smith", "Reference": "1234", "Keys": 
"5eac0bbd-82d7-4959-8496-2cdb13dea292" } ]  }

我想检索 Keys 的值

“钥匙”:“5eac0bbd-82d7-4959-8496-2cdb13dea292”

4

4 回答 4

1
var jsonParsed = JSON.parse(json);

var keys = jsonParsed.SearchAndSelect[0].Keys;

console.log(keys); // "5eac0bbd-82d7-4959-8496-2cdb13dea292"
于 2021-02-23T12:10:06.697 回答
0

采用 :

JSON.parse(`{"_Success": 1, "Criteria": "1234", "SearchAndSelect":  [ {"DateOfBirth": 
"15/02/1962","EmpNo": "123456","LastName": "John", "FirstName": "Smith", "Reference": "1234", "Keys": 
"5eac0bbd-82d7-4959-8496-2cdb13dea292" } ]  }`)
于 2021-02-23T12:09:21.493 回答
0

SearchAndSelect 是您应该在其中搜索的 JSON 的键。它是 JSONS 的列表,因此如果您使用 javascript,您可以执行以下操作

let data = JSON.parse(result)

for(let element of data.SearchAndSelect){
    console.log(element.Keys)
}

如果 SearchAndSelect 数组中有多个值,则此处理

于 2021-02-23T12:13:25.690 回答
0

var data = {"_Success": 1, "Criteria": "1234", "SearchAndSelect":  [ {"DateOfBirth": 
        "15/02/1962","EmpNo": "123456","LastName": "John", "FirstName": "Smith", "Reference": "1234", "Keys": 
        "5eac0bbd-82d7-4959-8496-2cdb13dea292" } ]  };

    for (const property of data['SearchAndSelect']) {
          console.log(property['Keys']);
    }

于 2021-02-23T12:20:44.417 回答