libmir / asdf

JSON library
http://asdf.libmir.org
Boost Software License 1.0
20 stars 8 forks source link

Error location in JSON #9

Closed LittleWally closed 4 years ago

LittleWally commented 4 years ago

How could I determine the position in the JSON string where ASDF deserialisation fails?

9il commented 4 years ago

asdf version v0.6.7 (just released) allows getting faulty location.

import asdf;
try
{
    auto data = `[1, 2, ]`.parseJson;
}
catch(AsdfException e)
{
    import std.conv;
    /// zero based index
    assert(e.location == 7);
    return;
}