cost 293 ms
將變量替換為 jsonpath_ng 查找字符串時出現錯誤“TypeError: must be str, not dict”

[英]getting error "TypeError: must be str, not dict" when substituting variable into jsonpath_ng find string

嗨希望有人能幫忙。 我是 python 的新手,想將變量傳遞給 jsonpath_ng 查找函數。 在我的代碼中,如果我對 json 過濾器進行硬編碼,它就可以工作,並且我得到一個結果,表達式類型為“jsonpath_ng.jsonpath.Child”,但如果我使用 f-string 構建一個變 ...

Python 和 jsonpath_ng 的 JSONPath 問題(在令牌附近解析錯誤?)

[英]JSONPath issues with Python and jsonpath_ng (Parse error near token ?)

我正在嘗試使用 jsonpath_ng Python 庫。 對於我通常使用的大多數 JSONPath 過濾器,它都有效。 但是,我正在為一個簡單的過濾子句而苦苦掙扎。 可以概括為2行。 我的 JSON 有效載荷是這個: } 我需要為每個具有特定“storagePolicyName”的 objec ...

使用 jsonpath_ng 檢查數組中的元素失敗並出現 JsonPathParseError

[英]Checking for an element in an array with jsonpath_ng fails with JsonPathParseError

我正在嘗試過濾我的 JSON 數據的元素,這些數據包含 Python 中帶有 jsonpath_ng 的數組中的特定值。 數據看起來像 使用查詢$[?(@.test contains "a2")]或$[?("a2" in @.test)]測試 PyCharm 中的數據可以正常工作並返回預期結果 不 ...

使用 jsonpath-ng 過濾

[英]Filter with jsonpath-ng

使用以下 json 數據: 使用表達式"$.data.level1[*][?(childName=='first')]"的 jsonpath 搜索/過濾器可以正確定位數據。 但是,使用表達式"$.data.level1[*][?(levelName=='level11')]"返回空白 如何在“l ...

JSONPath - 過濾器表達式未按預期工作

[英]JSONPath - Filter expression is not working as expected

無法讓 JSONPath 工作。 JSON: 小路: $.data[*].attributes[?(@.name=='ID')] 在jsonpath.com或在 python 中使用jsonpath-ng時返回不匹配。 我從根本上錯過了什么,這個過濾器不起作用? 注意:最終目標是獲取name和co ...

我們如何在 jsonpath_ng python 中使用正則表達式過濾器,它將 / 視為 SORT 方向。 有什么選擇嗎?

[英]How do we use regex filter in jsonpath_ng python, it treats / as SORT Direction. any alternative?

我正在嘗試查找其 Worker 值包含數字 880099 為 substring 的 Worker。 在這里,我正在嘗試使用她的員工 ID 查找 priyanka 的詳細信息。 我的代碼。 JSON 數據:[{“休假條目”:“2021 年 2 月 1 日 - 1 天(Divakar (77877 ...

Python jsonpath-ng:如何從 jsonpath 和值構建 json 文檔?

[英]Python jsonpath-ng : How to build a json document from jsonpath and values?

在 python 中開發,我想從 jsonpath 和相應值的列表創建一個 json 文檔(樹)。 例如,從 jsonpath 和一個值“acme”,它將創建: 然后,我應該能夠在 json 文檔中添加一個新節點,該節點由另一個具有給定值的 jsonpath 指定。 例如添加 jsonpath $ ...

如何使用 jsonpath-ng 算法?

[英]How to use jsonpath-ng arithmetic?

jsonpath-ng package 聲稱支持基本算術( https://pypi.org/project/jsonpath-ng/ ),但解析器不接受算術語句。 這是其中之一:from jsonpath_ng import parse jsonpath_expr = parse('$.ob ...

有沒有辦法使用 jsonpath-ng 從 JSON 中提取密鑰?

[英]Is there a way to extract the keys from JSON using jsonpath-ng?

我想從 JSON(實際上是 JSON Schema)創建一個鍵列表。 JSON 是復雜的和嵌套的,所以我使用 jsonpath-ng 庫。 我無法獲得密鑰列表。 另一方面,使用以下語法提取值是成功的: print([match.value for match in tagNames]) 。 嘗 ...

使用 jsonpath-ng 在 Python 中使用上下文更新 json 數據

[英]Update json data with context in Python using jsonpath-ng

在使用 jsonpath 更新 Python 中的 json 節點之后,想知道在給定特定上下文的情況下如何更新 JSON 數據。 因此,假設我們選擇完全相同的 JSON 示例: 但這一次,想將原始值加倍,因此需要考慮當前節點值的 lambda function。 ...

使用 jsonpath_ng 添加新節點

[英]Adding a new node using jsonpath_ng

在使用 jsonpath_ng 導航到 JSON 的特定部分后,我想添加一個節點,如下所示: 這將給出以下 output: {'server': 'ServerA', 'ip_address': '192.168.1.1', 'port': '80'} 現在我希望能夠將{'action_status ...

使用 jsonpath-ng 查找 json 對象的父對象

[英]find parent for a json object using jsonpath-ng

我有一個像下面這樣的 json obj。 我需要找到所有“聲明”和各自的父母。 我能夠找到“聲明”。 但是,不知道如何提取它們各自的父級。 我正在使用 Python3,jsonpath_ng。 到目前為止,這是我的代碼: 預期的父項:“AssumeRolePolicyDocument”和“Pol ...


排序:
質量:
 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM