Greetings,

I'm targeting the boost JSON library for an embedded target.  There appears to be one place where there could be either a beneficial new feature, or the feature exists and I'm not seeing it.

The section about Avoiding Dynamic Allocation is close to what we'd like to see, except that we don't want to depend on a stack buffer for value data.  All of the text of the JSON message is present in the string view.  It would be desirable to reference the values from there.

Let me be a little more explicit.

We receive a message in JSON format.  The whole of this message must be received before we can pass it to the JSON parser.  It's /possible/ to let the JSON parser manage the message as it arrives and manage both the parse and storage of the content.  Doing so would require shifting some responsibilities within the firmware that are difficult to change.

We parse out the fields we care about and then want to hold onto these values for some time without retaining the memory necessary for the parse itself.  Since all of the values and keys are present in the original source buffer passed to parse() as a string_view, we could simply save the string_views for the values and discard the JSON parser.  Except, this parser copies the value to another buffer s.t. discarding the parser invalidates the value string_views.

Alternatively, if the values themselves were returned as string_views into the source buffer, these string_views would (could) survive destruction of the parser.

If we are missing the method by which this can be implemented with the current parser, we'd be delighted to hear it.

Cheers

--
Marc Oscar Singer
Woollysoft
+1.206.328.1718