Skip to content

JSON encoding: allow writing to streams directly #10408

@julianbrost

Description

@julianbrost

Currently, the only JSON encoding function we use within Icinga 2 is the following that takes an input and returns the full JSON as a string:

String JsonEncode(const Value& value, bool pretty_print = false);

Having another option that can write to some stream similar to json.Encoder in Go would be desirable (example usage).

The first step for this issue should be to evaluate options on how to best do this in C++. Questions:

  1. What should the stream type be? Some standard ostream? Some Asio stream? Something else?
  2. Is the way we currently generate JSON really the best way? At least when looking at https://github.com/Icinga/icinga2/blob/master/lib/base/json.cpp, my gut feeling is that this does quite some low-level JSON stuff given that we're using a JSON library (emitting JSON tokens, handling pretty printing).

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions