Skip to content

Commit

Permalink
description for refactored lib
Browse files Browse the repository at this point in the history
  • Loading branch information
sjuergen committed Sep 15, 2022
1 parent a2fa92c commit 6492bf5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions docs/JsonDocument.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand All @@ -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.
Expand Down

0 comments on commit 6492bf5

Please sign in to comment.