WagoAppJSON and FOR loops

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 :

It’s really convenient when it comes to nested or array JSON data.
(Looks like a good beer is on the way :slight_smile: )

Will have a look at the SAX parser ! Thanks :slight_smile:

Hopefully there will be som good beer soon. Re-writing my code and moving from e! to codesys 3.5 at the same time :smiley: 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

Hej Thomas,

If you wish to have a ready-made example of how to parse JSON string with SAX parser then look here:

1 Like

Thanks! Will have a look :raised_hands: