serialization

Why is the first constructor called after deserialization and no others

本小妞迷上赌 提交于 2019-12-24 16:12:50
问题 please can someone explain why the constructor of the class 'Gambler' is called after deserialization but say the constructor of the class 'Player' is not? import java.io.*; class Gambler { Gambler() { System.out.print("d"); } } class Person extends Gambler implements Serializable { Person() { System.out.print("c"); } } class Player extends Person { Player() { System.out.print("p"); } } class CardPlayer extends Player implements Serializable { CardPlayer() { System.out.print("c"); } public

Java: Serialization doesn't work for the second time

与世无争的帅哥 提交于 2019-12-24 16:12:34
问题 I have a server on which I keep track of some data. When I connect to the server with the administrator application to check out the current state of the data. I use a refresh rate of 5 seconds. The first time the server sends the data, it works. But the second time, when the data changed, the admin-side does not receive the up-to-date data. I'm sending the data, wrapped in a class, through an ObjectOutputStream and ObjectInputStream: This is the wrapper class for the data: public class

Deserialize JSON from Riot API C#

时光毁灭记忆、已成空白 提交于 2019-12-24 15:46:06
问题 I have some problem to deserialize JSON response from the RIOT API in C#. I want to get the list of "Champion" and the API return a stream like this : { "type":"champion", "version":"6.1.1", "data":{ "Thresh":{ "id":412, "key":"Thresh", "name":"Thresh", "title":"the Chain Warden" }, "Aatrox":{ "id":266, "key":"Aatrox", "name":"Aatrox", "title":"the Darkin Blade" },... } } All data has the same attributes (id, key, name and title) so I create a champion class : public class Champion { public

WCF serialization ignores XmlRoot name with class implement IXmlSerializable

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-24 15:33:00
问题 Here is my WCF service class: class MyService : IMyService { public String GetService(MyRequest request){...} } Here is the request class: [XmlRoot("RequestClass")] class MyRequest : IXmlSerializable { public String Id {get;set;} public String ReqContent {get;set;} public void ReadXml(XmlReader reader) { using (XmlReader rr = reader.ReadSubtree()) { Id = ...; ReqContent = ...; } } public void WriteXml(XmlWriter writer) { // write customize format content to the writer } } The serialization of

Is having 'minOccurs=0' sufficient to cause .NET to create a xxxSpecified field

本秂侑毒 提交于 2019-12-24 15:21:54
问题 I have consumed a WSDL and one of the fields was from a enum type and in the generated reference.cs it created two fields for this: The field was called 'IsPayment' and it generated one called IsPaymentField and IsPaymentFieldSpecified I read from this answer: Why isn't my public property serialized by the XmlSerializer? That items with public bool xxxSpecified with value of false are not serialized So I manually in code set it to True and it worked. But what has caused this field to generate

hooking into the deserialization process

自古美人都是妖i 提交于 2019-12-24 15:07:11
问题 I have a DateRange object that represents the notion of Infinity via Static reference as shown below. As you see, the end points that define Infinity are also static references in a different class, DatePoint.Past and DatePoint.Future . Now I need to serialize this (as part of a deep Clone method that uses serialization) and know when it's deserialized that an instance with DateTime.Min and DateTime.Max as endpoints then the instance should be DateRange.Infinity . So I think I need to make it

Why is a complex string (stringified json data) not accepted as a POST parameter to a Web API method, but a simple string is?

核能气质少年 提交于 2019-12-24 14:53:16
问题 I want to send a bunch of data, converted to json, as a string, to a Web API POST method. I can send a simple string just fine, but when I try to send stringified json data, the method is not even reached - apparently the complex string is not viewed as a valid string value or something. This works, when passing "randomString" from the client: Web API [Route("{unit}/{begindate}/{enddate}/{stringifiedjsondata}")] [HttpPost] public void Post(string unit, string begindate, string enddate, string

How to deserialize JSON to C# class which uses composition

隐身守侯 提交于 2019-12-24 14:47:53
问题 I need to deserialize {'Id': 'id123', 'Time': 1436231503, 'Name': 'foo', 'ProductId': 1} into Container1 public class Container1 { public CommonFields Common { get; set; } //fields specific to Container1 [JsonProperty(PropertyName = "Name")] public string Name { get; set; } [JsonProperty(PropertyName = "ProductId")] public int ProductId { get; set; } } and { 'Id': 'id123', 'Time': 1436231503, 'Group':'10768C21-9971-4D2F-ACD7-10C2EF19FCA8' } into Container2 public class Container2 { public

C++, ECS and Saving / Loading

时光怂恿深爱的人放手 提交于 2019-12-24 14:44:24
问题 I have a program that employs an entity-component-system framework. Essentially this means that I have a collection of entities that have various components attached to them. Entities are actually just integer ID numbers, and components are attached to them by mapping the component to the specified ID number of the entity. Now, I need to store collections of entities and the associated components to a file that can be modified later on, so basically I need a saving and loading functionality.

.serialize() an array of variables in Javascript

为君一笑 提交于 2019-12-24 14:28:43
问题 I have a list of variables available to me and I want to send it via $.ajax post. What format would I have to keep these in to use the function .serialize? I keep getting this error: Object 'blank' has no method 'serialize' I've tried to make them an array and I've tried jQuery.param(). I have a feeling this is simple but I can't seem to get it. Thanks! var $data = jQuery.makeArray(attachmentId = attachmentID, action = 'rename', oldName = filename, newName, bucketName, oldFolderName,