Using System.Text.Json deserialization issues #2483
Replies: 5 comments
-
Is there a reason you're implementing this yourself? There's already built in support for STJ and it handles this particular problem. |
Beta Was this translation helpful? Give feedback.
-
@Hawxy , I'm aware this is already implemented. I plan on using a different serializer (likely MessagePack) when I get the time to deal with the whole serialization topic in the app. By "this particular problem" were you referring to the |
Beta Was this translation helpful? Give feedback.
-
I'm not sure how that would work. Marten uses jsonb selectors and thus serializing to encoded MessagePack would break a lot of functionality.
The |
Beta Was this translation helpful? Give feedback.
-
@talfirevic MessagePack would never work for the document storage. That would completely break the Linq support. |
Beta Was this translation helpful? Give feedback.
-
I'm switching this to a discussion as there's not anything to "fix" in Marten itself. @talfirevic My advice is to just use the built in STJ serialization strategy here that was built to be able to support Linq querying. |
Beta Was this translation helpful? Give feedback.
-
I've set up
System.Text.Json
as a default serialized by implementingISerializer
and I'm having issues with a basic use case - store and retrieve an entity.this is the relevant part of the CustomSerializer
Storing an object invokes
ToJson
, and it works as intended.Querying that same entity gets the item from the database, but when
FromJson<T>
is invoked, deserialization breaks because the string starts with0x01
for some odd reason.I'm missing something very obvious, aren't I?
P.S. when the object is being stored, the serializer does not produce a JSON string with
0x01
at the beginning, it only happens when I retrieve the object from the database.Beta Was this translation helpful? Give feedback.
All reactions