Skip to content

Commit

Permalink
Fixed bug in JSONEncoder when trying to create a member whose value i…
Browse files Browse the repository at this point in the history
…s an object
  • Loading branch information
michmela44 committed Oct 9, 2023
1 parent 989cd58 commit 7ba1243
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 10 additions & 0 deletions FluidNC/src/WebUI/JSONEncoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,16 @@ namespace WebUI {
add(']');
}

// Begins the creation of a member whose value is an object.
// Call end_object() to close the member
void JSONencoder::begin_member_object(const char* tag) {
comma_line();
quoted(tag);
add(':');
add('{');
inc_level();
}

// Starts an object with {.
// If you need a named object you must call begin_member() first.
void JSONencoder::begin_object() {
Expand Down
10 changes: 6 additions & 4 deletions FluidNC/src/WebUI/JSONEncoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ namespace WebUI {
void indent();
void line();

// begin_member() starts the creation of a member.
void begin_member(const char* tag);

std::string linebuf;

std::string* _str = nullptr;
Expand Down Expand Up @@ -58,10 +61,9 @@ namespace WebUI {
// end_object() closes the object with }
void end_object();

// begin_member() starts the creation of a member.
// The only case where you need to use it directly
// is when you want a member whose value is an object.
void begin_member(const char* tag);
// Begins the creation of a member whose value is an object.
// Call end_object() to close the member
void begin_member_object(const char* tag);

// The begin_webui() methods are specific to Esp3D_WebUI
// WebUI sends JSON objects to the UI to generate configuration
Expand Down

0 comments on commit 7ba1243

Please sign in to comment.