I’m trying to let the PFC200 talk directly to an api and remove Node-Red as a middle-man.
Struggelig to write this as ST while parsing the json:
for (i = 0; i < msg.payload.recipe.fermentation.steps.length; i++) {
fermTemp[i] = { payload: msg.payload.recipe.fermentation.steps[i].stepTemp }
fermTime[i] = { payload: msg.payload.recipe.fermentation.steps[i].stepTime }
fermPressure[i] = { payload: msg.payload.recipe.fermentation.steps[i].pressure };
}
Anyone got some examples how to parse json that includes arrays like the code above?
Hey Thomas, Have you take a look to the SAX parser ?
This is mentionned in this topic :
Hello. I’m trying and retrieve information from a JSON file. I manage to pick up the json string. But I can’t sort the data with WagoAppJSON.FbWrite_ToIEC_ByRule.
The data I try and retrieve is electricity prices in Norway during 24 hours.
link to json file https://www.hvakosterstrommen.no/api/v1/prices/2022/10-30_NO5.json
[image]
VAR
FbWrite_ToIEC_ByRuleStrom : WagoAppJSON.FbWrite_ToIEC_ByRule; // Function block to sort the info from the JSON file
stringPath : STRING(20):='/'; …
It’s really convenient when it comes to nested or array JSON data.
(Looks like a good beer is on the way )
Will have a look at the SAX parser ! Thanks
Hopefully there will be som good beer soon. Re-writing my code and moving from e! to codesys 3.5 at the same time Today I use Node-Red for parsing the recipe data and transfer it to the PFC using OPC UA. Got it talking directly to the api and just need to get everything parsed to get rid off Node-Red
1 Like
bo2022
February 7, 2023, 9:52am
4
Hej Thomas,
If you wish to have a ready-made example of how to parse JSON string with SAX parser then look here:
https://www.wago.com/se/svenska-applikationsexempel
1 Like