mirror of https://github.com/mamba-org/mamba.git
52 lines
1.1 KiB
C++
52 lines
1.1 KiB
C++
#ifndef MAMBA_JSON_HELPER_HPP
|
|
#define MAMBA_JSON_HELPER_HPP
|
|
|
|
#include <ostream>
|
|
|
|
#include "thirdparty/simdjson/simdjson.h"
|
|
|
|
void compute_dump(ParsedJson::iterator& pjh, std::ostream& os)
|
|
{
|
|
if (pjh.is_object())
|
|
{
|
|
os << "{";
|
|
if (pjh.down())
|
|
{
|
|
pjh.print(os); // must be a string
|
|
os << ":";
|
|
pjh.next();
|
|
compute_dump(pjh, os); // let us recurse
|
|
while (pjh.next())
|
|
{
|
|
os << ",";
|
|
pjh.print(os);
|
|
os << ":";
|
|
pjh.next();
|
|
compute_dump(pjh, os); // let us recurse
|
|
}
|
|
pjh.up();
|
|
}
|
|
os << "}";
|
|
}
|
|
else if (pjh.is_array())
|
|
{
|
|
os << "[";
|
|
if (pjh.down())
|
|
{
|
|
compute_dump(pjh, os); // let us recurse
|
|
while (pjh.next())
|
|
{
|
|
os << ",";
|
|
compute_dump(pjh, os); // let us recurse
|
|
}
|
|
pjh.up();
|
|
}
|
|
os << "]";
|
|
}
|
|
else
|
|
{
|
|
pjh.print(os); // just print the lone value
|
|
}
|
|
}
|
|
|
|
#endif |