c# - Switch from BinaryFormatter serialization without changing much: big data and circular references -


in our application maintained years use binaryformatter serialization of big data objects containing loads of collections , circular references. serialization takes forever (~20 seconds) , takes of cpu usage. i'd switch type of serialization better , light without changing code there not time given.

i've tried many of solutions of them need:

  • class decorating or many code changes (e.g. protobuf);
  • doesn't allow circular references (e.g msgpack);

is there way smoothly switch , better serializer without pain , improve serialization process?

after doing research , spending day on implementing available solutions - i'll go json.net.

i didn't have change switch binaryformatter, serializer attributes objects haven't change. runs way faster (~2 seconds same object size) , seems work properly.

to pass circular references , other errors had configure serializer:

jsonserializer serializer = new jsonserializer(); serializer.converters.add(new javascriptdatetimeconverter()); serializer.nullvaluehandling = nullvaluehandling.ignore; serializer.referenceloophandling = referenceloophandling.serialize; serializer.preservereferenceshandling = preservereferenceshandling.objects;  using (streamwriter sw = new streamwriter(filename)) {     using (jsonwriter writer = new jsontextwriter(sw))     {         serializer.serialize(writer, dbobject);     } } 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -