serialization

C# Binary Formatter Serialization & Deserialization - 3 Random Exceptions

依然范特西╮ 提交于 2020-02-08 10:10:15
问题 I'm creating a C# application (Client & Server). They're seperate projects and both reference a DLL that can serialize and deserialize any object that is inputed into them. Everything is working fine, until I start working with live desktop monitoring (Video-ish). The DLL contains a custom "Screenshot" class that takes in a bitmap & writes it to the public memorystream for that class. Here is how it is all done: Client button takes screenshot of whole screen (as a bitmap) Client constructs a

How to put serialize and get serializeContext in Kotlin Android?

巧了我就是萌 提交于 2020-02-08 10:06:33
问题 I want save and keep my state in fragment because when tap on recyclerView items and back to fragment with listener i lost my Context and my context in fragment is null . So i try to keep my context like this: override fun onSaveInstanceState(outState: Bundle) { super.onSaveInstanceState(outState) outState.putSerializable("SaveContext", context) } 回答1: You should initialize your context correctly. Check below as for example class MyFragment: Fragment() { private var mContext: Context? = null

How to exclude an instance variable from marshal dump

旧时模样 提交于 2020-02-08 01:44:08
问题 My object contains an instance variable that point to a File object amongst several other attributes. Because of this Marshal cannot serialize it. How can I write a bespoke dump method so to exclude only that instance variable? class Area attr_accessor :area attr_reader :several_other_attributes ........ def initialize(name) @area = name @several_other_attributes = .... @log = File.open( 'test.log', 'w') end end 回答1: You can very easily write a marshal_dump and marshal_load method that

How to serialize Java ZonedDateTime to XML file

▼魔方 西西 提交于 2020-02-07 05:28:44
问题 Error while serializing ZonedDateTime (it doesn't appear in the output xml at all): java.lang.InstantiationException: java.time.ZonedDateTime Continuing ... java.lang.RuntimeException: failed to evaluate: =Class.new(); Continuing ... I have an instance of the class, where one of the fields is of a type ZonedDateTime. When i'm trying to serialize the object with XMLEncoder: import java.beans.XMLEncoder; I get this errors. In the output file all the other fields appear except the field with

What could be the reason that my custom REST serializer is not working?

青春壹個敷衍的年華 提交于 2020-02-07 05:27:04
问题 Both methods MyBehavior::CreateSerializer() are not called of some reason, but ReplaceBehavior() method is working. It is changing default behavior with my custom one. Do someone know where could be the problem? The point is to write custom REST WCF serializer that should generate non-XML text format result. public class MySerializerFormatAttribute : Attribute, IOperationBehavior { public void AddBindingParameters(OperationDescription description, BindingParameterCollection parameters) { }

C# serialize JSON without property name

半城伤御伤魂 提交于 2020-02-06 11:22:48
问题 maybe this was asked somewhere before, but I don't know how to search for my problem. I'm using a WebAPI to verify licenses. From this API I get the return JSON string in follwing format. string json = "[{"status":"error","status_code":"e002","message":"Invalid licence key"}]" This is my serializer using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(json))) { DataContractJsonSerializer js = new DataContractJsonSerializer(typeof(ActivationResponseWooSl)); ActivationResponseWooSl ar =

C# serialize JSON without property name

我怕爱的太早我们不能终老 提交于 2020-02-06 11:22:27
问题 maybe this was asked somewhere before, but I don't know how to search for my problem. I'm using a WebAPI to verify licenses. From this API I get the return JSON string in follwing format. string json = "[{"status":"error","status_code":"e002","message":"Invalid licence key"}]" This is my serializer using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(json))) { DataContractJsonSerializer js = new DataContractJsonSerializer(typeof(ActivationResponseWooSl)); ActivationResponseWooSl ar =

JSON - Django/Webdatarocks: unable to correctly serialize data in JSON

让人想犯罪 __ 提交于 2020-02-06 07:57:45
问题 I currently develop a Django project and try to implement WebDataRocks WebDataRocks is a free web reporting tool for data analysis and visualization I works but my problem deal with correctly presenting data to be updated in Webdatarocks I would like to update each of my models. I have a views name data use with my template that load WebDataRocks def data(request): data = serializers.serialize("json", mymodel.objects.filter(med_ide__lte=10)) return render(request, 'myapp/data.html', {'data'

C# XML deserialization

邮差的信 提交于 2020-02-06 02:43:30
问题 I have xml that is returned with an array of different types of objects. I am having trouble with the xmlchoiceidentifier when it gets to the keyword struct. When it deserializes it, it just returns null. Here is the xml that I am trying to deserialize: <struct> <member> <name>result</name> <value><boolean>1</boolean></value> </member> <member> <name>user_info</name> <value> <struct> <member> <name>First Name</name> <value><string>John</string></value> </member> <member> <name>Last Name</name

Deserialization of java.utils.logging.Level class with Jackson returns null

天大地大妈咪最大 提交于 2020-02-04 22:18:49
问题 I am trying to deserialize a complex bean using jackson and Lombok builder. I have solved already many errors related to serialization of other custom types but I am stuck with deserializing a Level object. The serialization works somehow but not the deserialization as shown below. Since the Level class is protected, I cannot for instance create an auxiliary variable to serialize the Level object attributes in a different way (e.g. an array of strings) and then call the constructor of Level