diff --git a/README.md b/README.md index 4d19def..404989a 100644 --- a/README.md +++ b/README.md @@ -167,6 +167,7 @@ PROGRAM MyProgram END_VAR VAR doc : JsonDocument; + docBuffer : ARRAY[0..200] OF CHAR; myBoolean : JsonBoolean := (Value := TRUE, Key := 'myBoolean'); myInt : JsonInt := (Value := 1234, Key := 'myInt'); myDint : JsonDInt := (Value := DINT#12345678, Key := 'myDint'); @@ -190,6 +191,7 @@ PROGRAM MyProgram step := Steps#SerializeDocument2; Steps#SerializeDocument2: // Serialize the document {"myBoolean": true, "myObject": {"myInt": 1234, "myDint": 12345678}} + doc.buffer := REF(docBuffer); doc.Serialize(doc.buffer); SerializedDocument := Arrays.ToString(arr := doc.buffer); step := Steps#ParseDocument2; diff --git a/docs/JsonDocument.md b/docs/JsonDocument.md index c152941..56e5af1 100644 --- a/docs/JsonDocument.md +++ b/docs/JsonDocument.md @@ -10,7 +10,7 @@ classDiagram IJsonContainerElement<|--JsonDocument IJsonContainerElement : AddElement(IJsonElement) JsonDocument : STRING ToString() -JsonDocument : BOOL Serialize(ARRAY[*] OF CHAR) +JsonDocument : BOOL Serialize() JsonDocument : IJsonElement GetRootElement() JsonDocument : ClearBuffer(BOOL) JsonDocument : Reset() @@ -23,8 +23,8 @@ JsonDocument : Reset() Returns the JSON string of the JSON document (max. 254 characters) -### Serialize(IN_OUT buf : ARRAY[*] OF CHAR) : BOOL -Serializes the JSON document ino a ARRAY OF CHAR +### Serialize() : BOOL +Serializes the JSON document ino a ARRAY OF CHAR. JsonDocument.buffer must be set before. ### GetRootElement() : IJsonElement Returns root element of the JSON document @@ -33,7 +33,7 @@ Returns root element of the JSON document Add a new element to the JSON document ### ClearBuffer(hard : BOOL) -Clear the buffer logically (fast). If `hard = TRUE` then delete the buffer also physically (slow) +Clear the buffer logically (fast). If `hard = TRUE` then delete the buffer also physically (slow) JsonDocument.buffer must be set before. ### Reset() Reset the complete object tree and the destination buffer of the JSON document for the purpose, a new JSON object should be created.