# Parsing JSON with "FbWrite\_ToIEC\_ByRule" - Wago CC100 + Codesys V3

**URL:** <https://www.wago.community/t/json-parsen-mit-fbwrite-toiec-byrule-wago-cc100-codesys-v3/2919>\
**Category:** Feature and Product Requests\
**Created:** [October 21, 2026, 5:47am UTC](https://www.wago.community/t/json-parsen-mit-fbwrite-toiec-byrule-wago-cc100-codesys-v3/2919 "2026-10-21T05:47:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![FlyingDutchman](https://avatars.discourse-cdn.com/v4/letter/f/258eb7/32.png) [@FlyingDutchman](https://www.wago.community/u/FlyingDutchman)\
**Post date:** [October 21, 2026, 5:47am UTC](https://www.wago.community/t/json-parsen-mit-fbwrite-toiec-byrule-wago-cc100-codesys-v3/2919/1 "2026-10-21T05:47:01Z")

</div>

Hello everyone, I have a problem here that I’m not quite sure how to proceed with. Maybe someone could give me a hand.

An API request was used to read the JSON response from [https://api.awattar.at/v1/marketdata](https://api.awattar.at/v1/marketdata) into the controller via the function block “fbHTTP\_Client\_Curl” → This worked quickly.

This information now needs to be mapped to the corresponding target array via the function block “FbWrite\_ToIEC\_ByRule”. The receive buffer (sresponsebuffer) is a String variable with a size of 10,000 bytes. The target array “strompreis” in [Codesys](https://de.codesys.com/) has a size of 44 (0..43) and the data type “Strompreisdaten”.

The Problem: As soon as the block “FbWrite\_ToIEC\_ByRule” is triggered, it starts running but then stops at “iActualArrayRow”=13 and switches to fault mode.

Here are the declarations:

//Structure Strompreisdaten

{attribute ‘pack\_mode’ := ‘1’}  
TYPE strompreisdaten :  
STRUCT  
start\_timestamp :LINT; //in ms  
end\_timestamp :LINT; //in ms  
marketprice :REAL;  
unit :STRING(10);  
END\_STRUCT  
END\_TYPE

//Declaration:

var  
stringpath:‘/data’;  
strompreis [0..43] of strompreisdaten;

//Rule definition for electricity price query  
arrstromprrules :ARRAY[0..MAX\_ARRAY\_ELEMENTS\_CUSTOM] OF typRuleBase:= [  
(spath:=‘start\_timestamp’, iconverttype:=eLINT),  
(spath:=‘end\_timestamp’, iconverttype:=eLINT),  
(spath:=‘marketprice’, iconverttype:=ereal),  
(spath:=‘unit’, iconverttype:=estring)  
];

end\_var

VAR CONSTANT  
MAX\_ARRAY\_ELEMENTS\_CUSTOM :INT:=3;  
END\_VAR

Program code:

udibuffersize:=strlength(sbuffer:=sresponsebuffer,udisize:=SIZEOF(sresponsebuffer));

//Parse REST API response “json-string” with “FbWrite\_ToIEC\_ByRule”

auswertapianfrage\_strompreis(xtrigger:=xtriggerjsonparsing,spathbase:=stringpath,  
arule:=arrstromprrules,pdatain:=ADR(sResponsebuffer),udiSizeDataIn:=udibuffersize,  
piecvariable:=ADR(strompreis),  
udiSizeIecVariable:=SIZEOF(strompreis),iArraySizeIecVariable:=44,  
xerror=\>xErrorJSONParsing,ostatus=\>ostatus,iActualArrayRow=\>iActualArrayRow);

//negative edge  
ftrig1temp:= NOT xtriggerjsonparsing AND ftrig1stat;  
ftrig1stat:= xtriggerjsonparsing;

//Evaluation of Parser Status

IF xerrorjsonparsing THEN  
istat:=0;//Abort + Error handling  
xtriggerjsonparsing:=FALSE;  
ELSE  
;  
END\_IF

IF NOT xerrorjsonparsing AND ftrig1temp THEN  
istat:=0;//Parsing was successful  
ELSE  
;  
END\_IF

It would be great if someone could help me out. I’ve reached my wit’s end. I had parsed API requests before, but this time… Best regards.

---

<div class="post-metadata">

**Author:** ![MatthewKim](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@MatthewKim](https://www.wago.community/u/MatthewKim)\
**Post date:** [October 22, 2026, 12:29am UTC](https://www.wago.community/t/json-parsen-mit-fbwrite-toiec-byrule-wago-cc100-codesys-v3/2919/2 "2026-10-22T00:29:27Z")

</div>

Hello, I’m Matthew Kim, based in Korea.  
I’ve encountered a similar issue myself (though my data was more complex). I initially tried to solve it using only CODESYS, but I ran into problems with parsing—specifically, the data stream would cut off at unexpected points. To get around this, I took a different approach:

1. Install Node-RED (via Docker) on the CC100.
2. Use Node-RED to handle the parsing.
3. Transmit the data via Modbus.
4. Receive the data in CODESYS using Modbus TCP.

This method resolved the issue of the parsing unexpectedly stopping (or cutting off), and the results were quite satisfactory.

Just keep in mind that you’ll need to pay a bit more attention to the Modbus handshake process.  
I’m no expert in Node-RED myself, but Gemini can certainly help you with that. Once I decided to go this route, I was able to get it implemented in just two days.

Although the actual project has been delayed due to the client’s circumstances, this approach proved much faster to implement than continuing to struggle with the limitations within CODESYS.

If anyone else has managed to solve this kind of issue directly within CODESYS, please feel free to leave a comment!

---

<div class="post-metadata">

**Author:** ![wagoalex](https://sea2.discourse-cdn.com/flex016/user_avatar/www.wago.community/wagoalex/32/483_2.png) [@wagoalex](https://www.wago.community/u/wagoalex)\
**Post date:** [October 22, 2026, 7:43am UTC](https://www.wago.community/t/json-parsen-mit-fbwrite-toiec-byrule-wago-cc100-codesys-v3/2919/3 "2026-10-22T07:43:26Z")

</div>

Hi there,

Probably a string size miss match.

> [@FlyingDutchman](#):
>
> (spath:=‘unit’, iconverttype:=estring)

Try to use: (spath:=‘unit’, iconverttype:= **eString10** )

Additionally you could try to use {attribute ‘pack\_mode’ := ‘0’} , or is there a specific fix/reason why you´ve chosen to use the packed no padding mode so that fields sit back to back?

BR Alexander

---

<div class="post-metadata">

**Author:** ![FlyingDutchman](https://avatars.discourse-cdn.com/v4/letter/f/258eb7/32.png) [@FlyingDutchman](https://www.wago.community/u/FlyingDutchman)\
**Post date:** [October 25, 2026, 10:48pm UTC](https://www.wago.community/t/json-parsen-mit-fbwrite-toiec-byrule-wago-cc100-codesys-v3/2919/4 "2026-10-25T22:48:13Z")

</div>

Hello wagoalex, I tried it with the "estring10" like this. The whole thing works perfectly now. Thank you very much for the tip. Best regards.
