|
Boost : |
From: Kenneth Porter (shiva_at_[hidden])
Date: 2022-04-26 08:06:25
--On Monday, April 25, 2022 4:49 PM -0700 Vinnie Falco
<vinnie.falco_at_[hidden]> wrote:
> If your exception is coming from the call to parse() and you want to
> know where in the string you are, then you need to change your code to
> create an instance of json::parser and call parser::write or
> parser::write_some to feed in the input. These functions return the
> number of characters consumed, which will be less than the amount
> passed in if an error occurs. In this case, the number of characters
> parsed successfully can be used to calculate an offset into the input
> buffer to determine where the syntax error happened.
>
> If your exception is coming from the call to value_to<>(), things are
> not so simple. The original JSON string is no longer available, and
> information about which json::value came from what part of the string
> is not stored (that would slow down the library and take up
> unnecessary memory).
Aha, I begin to understand the issues. Two different classes of error can
occur. Catching a problem in the parse() call would catch JSON syntax
errors. My JSON was correct as it had been machine-generated from an online
XML translator. I was seeing semantic errors in turning a valid JSON
structure into my custom C++ structure. So I somehow need to figure out
where in the hierarchy the translation failed. Given that, I could output
the JSON structure as text with an indicator where the structure wasn't
what the translator expected.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk