forked from bblanchon/ArduinoJson
Fixed empty object output
This commit is contained in:
@ -11,14 +11,32 @@ size_t IndentedPrintDecorator::write(uint8_t c)
|
|||||||
{
|
{
|
||||||
case '{':
|
case '{':
|
||||||
indent++;
|
indent++;
|
||||||
return sink.write(c) + writeln();
|
emptyBlock = true;
|
||||||
|
return sink.write(c);
|
||||||
|
|
||||||
case '}':
|
case '}':
|
||||||
indent--;
|
indent--;
|
||||||
return writeln() + sink.write(c);
|
|
||||||
|
if (emptyBlock)
|
||||||
|
{
|
||||||
|
return sink.write(c);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return writeln() + sink.write(c);
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return sink.write(c);
|
|
||||||
|
if (emptyBlock)
|
||||||
|
{
|
||||||
|
emptyBlock = false;
|
||||||
|
return writeln() + sink.write(c);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return sink.write(c);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ class IndentedPrintDecorator : public Print
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
IndentedPrintDecorator(Print& p)
|
IndentedPrintDecorator(Print& p)
|
||||||
: indent(0), sink(p)
|
: indent(0), sink(p), emptyBlock(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,6 +21,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
int indent;
|
int indent;
|
||||||
|
bool emptyBlock;
|
||||||
Print& sink;
|
Print& sink;
|
||||||
|
|
||||||
size_t writeln();
|
size_t writeln();
|
||||||
|
Reference in New Issue
Block a user