Code: Select all
[h: Location = "Backpack1"]
[h: ItemKey = "Blanket, woollen"]
[h: jGearList = '{"OnPerson":{"Contents":{"Backpack1":{"Type":"Backpack","Weight":"10","Cost":"2gp","Capacity":"50","Contents":{"Blanket, woollen": "Yes"},"ContentWeight":0},"Backpack2":{"Type":"Backpack","Weight":"10","Cost":"2gp","Capacity":"50","Contents":{},"ContentWeight":0},"Backpack3":{"Type":"Backpack","Weight":"10","Cost":"2gp","Capacity":"50","Contents":{},"ContentWeight":0}},"ContentWeight":0},"NotOnPerson":{"Contents":{},"ContentWeight":0}}']
[h: xExpression = "\$..['" + Location + "']['Contents']['" + ItemKey + "']"]
[r: xExpression]
[jItemArray = json.path.read(jGearList, xExpression) ]
[r: jItemArray ]
I get 'Error with function "json.path.read": Found empty property at index 47'
The expression and json work okay at this json path expression tester: https://jsonpath.curiousconcept.com/
To run it there, you can paste this json:
Code: Select all
{"OnPerson":{"Contents":{"Backpack1":{"Type":"Backpack","Weight":"10","Cost":"2gp","Capacity":"50","Contents":{"Blanket, woollen": "Yes"},"ContentWeight":0},"Backpack2":{"Type":"Backpack","Weight":"10","Cost":"2gp","Capacity":"50","Contents":{},"ContentWeight":0},"Backpack3":{"Type":"Backpack","Weight":"10","Cost":"2gp","Capacity":"50","Contents":{},"ContentWeight":0}},"ContentWeight":0},"NotOnPerson":{"Contents":{},"ContentWeight":0}}
Code: Select all
$..['Backpack1']['Contents']['Blanket, woollen']