Karak Posted June 22, 2022 Report Share Posted June 22, 2022 So I have a simple REST-server running with an endpoint at https://10.0.0.245:7001/prices The endpoint returns an array of integers that I want to store on the PLC. I tried the setup in the attached images, but all I get is a "Invalid path to value" error. (Only attempting to grab and store the first array-item to begin with). Does anyone know how to solve this? Quote Link to comment Share on other sites More sharing options...
Elad S Posted July 4, 2022 Report Share Posted July 4, 2022 Hello, It would help if you upload the json you are trying to parse. Also currently there is no support for parsing directly into array. You can parse an array member into a tag. That means you can ask for all the array members and fill an array. You can parse the json into a buffer and then do what ever you want with the data. 2 Quote Link to comment Share on other sites More sharing options...
Karak Posted July 5, 2022 Author Report Share Posted July 5, 2022 Thank you for for your response. The json looks like the attached example, or in the linked pastebin. It's just a simple array of integers at the moment, but I can change the format if that is necessary. json-example - Pastebin.com example.json Quote Link to comment Share on other sites More sharing options...
Elad S Posted July 6, 2022 Report Share Posted July 6, 2022 I see your json main brackets are [] which means it's an array and not an object. It's a special case which requires you to mark the "IsArray" checkbox and choose the "Main Array Index". In the example below you can see I asked for the second index. The "Path Preview" is '/' because you ask for values at the first level and they have no key. The "Main Array Index" tells us which member to take when there is no key given on the first level. Your json: [ 1 , 2 , 3 , 4 ,5 , ..., 23] What you tried to do is for a json that looks like this: { "level1": [0, 1, 2, 3] } And you asked for level1[0] (Your "Path Preview" is /level1[0]/). That will get you the value 0. (If you json would actully look like this) Hope this helps. 2 Quote Link to comment Share on other sites More sharing options...
Karak Posted July 6, 2022 Author Report Share Posted July 6, 2022 Thank you. I get an error message saying "Response Parameter must have at least one level" when I copy your image, but I got it working by changing the JSON to { "level1": [0, 1, 2, 3,.....] } and using the following parameters: And it works, so I'll do some experimentation from there on the best way to format the JSON. Thank you once again for your help. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.