langium icon indicating copy to clipboard operation
langium copied to clipboard

JsonSerializer and References

Open cdietrich opened this issue 1 year ago • 2 comments

Currenty the JsonSerializer can't (de)serialize References that cannot be resolved. It would be nice to have an flag in the JsonSerializeOptions to omit serializing the reference?

do i overlook something that makes this impossible? (am not sure about the derserialization aspects)

our usecase is to test the parser. there we care about the ast structure only and not any errors in resolving

cdietrich avatar Apr 18 '24 04:04 cdietrich

Just to clear things up, because I haven't tried it yet. Does the JsonSerializer throw an error when trying to serialize a non-resolved reference?

msujew avatar Apr 18 '24 08:04 msujew

no but it includes

{
 "ref": Object {
"$refRef": b, 
           "$error": "Could not resolve reference to NamedDotTargetReference named 'b'.",
            }
}

but we dont care about $error (or the uri) when asserting on the ast

cdietrich avatar Apr 18 '24 10:04 cdietrich