All data value conainers include an insertion << operator that can send data to a stream in a JSON formatted way. If the data value is a complex one, this insertion operation will recursively generate JSON formatted data for each of ist components.
So, in a general case, creating JSON data is a matter of populating a data value structure and invoke the insertion operation on the outermost data value component. In this trivial example, data population was automatically performed by the previuos parsing operation and no direct program intervention is required.
We can say that this program behaves like an echo filter that outputs a replic of its input (although parsing process reduces additional spaces, tabs, linefeeds, etc. data meaning is kept unaltered between jparse input and output) and, beyond JSON conversion back and forth it behaves like:
int main()
{
while (true)
{
char c;
std::cin.get(c);
if (std::cin.fail())
break;
std::cout << c;
}
return 0;
}
RSS Feeds