Open hfhbd opened 4 months ago
I may add support for this, but it can't be default behaviour in all cases as it requires having access to the original string (you don't want to do this on streaming). Note that it already provides line/character number as well as the context (type, parentTagName/unknownName) and the expected names (and what type they are). It does provide namespaces, but hides empty namespaces to keep the output compact.
Yes, I don't expect the full input string, but the failed element only, which is already needed by the parser/decoder, isn't it? With large inputs, the full string is also not really helpful too.
AFAIK the json deserializer also only contains the current item (and the next x characters).
@hfhbd The problem is that for element (rather than attribute) children the "current" element is the child, rather than the container/parent. And the place in the code where this triggers is used to resolve both tag and attribute names.
Like kotlinx.serialization.json, it would be helpful to include the content when decoding, ideally the attribute/element (including its namespace) that failed.
Given class:
Using json
Json.decodeFromString(A.serializer(), """{"a": "b", "d": 42}""")
:Using xml
XML.decodeFromString(A.serializer(), """<A a="asd" d="asfd"/>""")
: