20 for(
const auto &ch : src)
79 out << std::string(indent*2,
' ');
91 for(arrayt::const_iterator a_it=
array.begin();
95 if(a_it!=
array.begin())
101 out << std::string((indent+1)*2,
' ');
106 a_it->output_rec(out, indent+1);
109 if(
array.back().is_object())
110 out <<
'\n' << std::string(indent*2,
' ');
137 for(objectt::const_iterator o_it =
object.begin(); o_it !=
object.end();
140 if(o_it !=
object.begin())
147 out << std::string((indent + 1) * 2,
' ');
150 o_it->second.output_rec(out, indent + 1);
165 other.
object.swap(
object);
187 const auto &left_array =
static_cast<const json_arrayt &
>(left);
188 const auto &right_array =
static_cast<const json_arrayt &
>(right);
189 return left_array.
size() == right_array.size() &&
191 left_array.begin(), left_array.end(), right_array.begin());
195 const auto &left_object =
static_cast<const json_objectt &
>(left);
196 const auto &right_object =
static_cast<const json_objectt &
>(right);
197 if(left_object.size() != left_object.size())
202 [&](
const std::pair<std::string, jsont> &pair) {
203 return right_object[pair.first] == pair.second;
217 for(
const auto &sub_entry : entry.
children())
219 result[sub_entry.first.camel_case()] =
json_node(sub_entry.second);
221 return std::move(result);
227 if(data.
data().size() == 0)
231 for(
const auto &sub_entry : data.
data())
233 result[sub_entry.first.camel_case()] =
json_node(sub_entry.second);
235 return std::move(result);
static void escape_string(const std::string &, std::ostream &)
void output_rec(std::ostream &, unsigned indent) const
Recursive printing of the json object.
static void output_key(std::ostream &out, const std::string &key)
std::map< std::string, jsont > objectt
static const jsont null_json_object
static void output_object(std::ostream &out, const objectt &object, unsigned indent)
Basic handling of the printing of a JSON object.
A way of representing nested key/value data.
const std::map< labelt, structured_data_entryt > & data() const
jsont to_json(const structured_datat &data)
Convert the structured_datat into an json object.
bool operator==(const jsont &left, const jsont &right)
jsont json_node(const structured_data_entryt &entry)
#define UNREACHABLE
This should be used to mark dead code.
const std::map< labelt, structured_data_entryt > & children() const
jsont leaf_object() const