我一直在构建一个应用程序,其中JSON将从用户API中提供。它应该使用JSONPath从JSON读取数据,并持久化所选的部分。我正在尝试使用Json.Net (Newtonsoft)来完成这个任务。下面的JSON是一个示例:
{
// other properties here and different structure here
"Data": [
{
"Code": "625087",
"Name": "Customer Name",
"Emai
我提取包含字符串列表的JsonArray,并希望通过正则表达式验证该对象中的每个字符串。问题是,我似乎在金牛座的网站上找不到任何答案。你知道我该怎么做吗?例子如下:
# Verification of value inside the JsonArray
extract-jsonpath:
names: $.names
- foreach: name in names
do:
- jsonpath: ${name} # if this JSONPATH is not found, assert will fail
validate: true
我想从JSON (实际上是JSON )创建一个键列表。JSON是一个复杂的嵌套库,所以我使用jsonpath-ng库。
我没办法拿到钥匙的清单。另一方面,使用以下语法:print([match.value for match in tagNames])提取值是成功的。
尝试使用类似的语法提取密钥,比如.
from jsonpath_ng import jsonpath, parse
import json
filePath = "./sample.json"
with open(filePath, "r") as jsonFile:
jsonData