c# - How to use SQLite-Net Extensions without Json.Net dependency (with alternative ITextBlobSerializer)? -


i writing plugin (.net framework 4.61) uses sqlite-net extensions. these require newtonsoft's json.net present itextblobserializer. json.net in turn requires system.numerics reference.

the plugin can not use nuget packages , has submitted zipped source compiled on servers of application provider. challenge @ hand application compiler not support system.numerics , system.numerics not embeddable interop type. request system.numerics added has been ignored.

since have no way of using system.numerics best approach rid of json.net , replace itextblobserializer own implementation.

is able provide itextblobserializer implementation has no other dependencies? not sure how proceed on front.

turns out not difficult. removed jsonblobserializer.cs file depending on json.net. created own itextblobserializer implementation utilizes javascript serializer this:

using system; using system.web.script.serialization; using sqlite.extensions.textblob;  public class blobserializer : itextblobserializer {     private readonly javascriptserializer serializer = new javascriptserializer();      public string serialize(object element)     {         var str = serializer.serialize(element);         return str;      }      public object deserialize(string text, type type)     {         var result = serializer.deserialize(text, type);         return result;     } } 

finally edited gettextserializer method in textbloboperations.cs own itextblobserializer became default:

    public static itextblobserializer gettextserializer()     {         // if not specified, use javascript serializer         return _serializer ?? (_serializer = new blobserializer());     } 

Comments

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -