deserialization

exception: boost::archive::archive_exception at memory location

↘锁芯ラ 提交于 2020-01-03 19:40:42
问题 When I try to deserialize binary data I get this: exception: boost::archive::archive_exception at memory location write: std::ofstream ofs(savePath); boost::archive::binary_oarchive out_arch(ofs); out_arch << mData; ofs.close(); read: std::ifstream ifs(loadPath); boost::archive::binary_iarchive in_arch(ifs); in_arch >> _mData; When i use text_iarchive \text_oarchive work fine. Serialized data structure mData is ColorMatrix<std::map<int, float>> mData; #include <algorithm> #include <memory>

Deserializing JSON data in Mono

无人久伴 提交于 2020-01-03 17:44:59
问题 Is there an easy way to deserialize a simple JSON string into a .NET object when using Monodroid? System.Json only provides serialization (no deserialization) and the various third party libs I've tried were all causing problems with Mono/Monodroid. Thank you. 回答1: fastJSON suits the bill. Grab the required files (Getters.cs, JSON.cs, JsonParser.cs, JsonSerializer.cs, SafeDictionary.cs) and embed them in your project and use it. It doesn't use any fancy .NET specific class so it should work

jsonrpc4j: How to add type info to parameters?

左心房为你撑大大i 提交于 2020-01-03 17:13:06
问题 I am using jsonrpc4j and got stuck. I made a little example to show my problem: Abstract class: @JsonTypeInfo(use = JsonTypeInfo.Id.NAME) @JsonSubTypes(value = { @JsonSubTypes.Type(value = Walnut.class) }) public abstract class Nut { } Concrete subclass: public class Walnut extends Nut { } Interface for the service: public interface ServiceInterface { public Nut getNut(); public void setNut(Nut nut); } The service itself: public class Service implements ServiceInterface { public Nut getNut()

C# Google.ProtocolBuffers Deserialization Method (proto3)

眉间皱痕 提交于 2020-01-03 15:34:11
问题 I have recently upgraded my code base (Java, C++ and C#) to use proto3. In the case of C# this has involved over 2000 changes to the code. This is mostly semantic and all good, but there is one issue I can't seem to fathom; serialization/deserialization. I have the following amended method to desearialize my IMessage types (the code to do this in proto2 is commented), this is the code that is show in the examples within the GitHub repository... public static T ToObject<T>(this byte[] buf)

WCF List<string > serialization/deserialization error

柔情痞子 提交于 2020-01-03 08:42:40
问题 I have the following ServiceContract and DataContract classes: [ServiceContract] public interface IWcfService { [OperationContract] Response GetData(); } [DataContract] public class Response { [DataMember] public Dictionary<string, object> Data { get; set; } } When the value of Response.Data dictionary is of type int, string, double or any other 'simple' primitive types, WCF can successfully serialize the object. But when the value of Response.Data dictionary is of type List< string>, the

Converting two-dimensional array to an object c#

本小妞迷上赌 提交于 2020-01-03 05:35:06
问题 This all originates from querying Google Analytics data. For a basic query the main factors that change are the dimensions and the metrics . The object that is returned is of a type called GaData, and the actual results that you need reside in GaData.Rows. The format of GaData.Rows looks like this: There will first be a row for each dimension, in this example there is a row for "New Visitor" and a 2nd row for "Returning Visitor". Within those rows will be another set of rows that contain the

How to serialize ArrayList 2x and dont over write the already present ArrayList JAVA

ぃ、小莉子 提交于 2020-01-03 05:11:28
问题 I'm stuck with making an admin panel for my program to serialize more objects, what it does is , it saves object(String,String) into arraylist and the arraylist is saved into file through serialization. When trying to add another object into the arraylist, The program first deserialize the file stuff into the arraylist, because by not doing this how would i access the objects that are already present in the file.? but instead something like this happens while adding object 3 (console) Index 0

Jackson JSON de-serialization with views

╄→尐↘猪︶ㄣ 提交于 2020-01-03 04:32:08
问题 Im trying to serialize a property based on the view. Unfortunately the code below doesn't work as Jackson reports a conflicting getter propperty "userId". Is there any way to get an object according to the view in an specific representation? @JsonView(Views.Mongo.class) @JsonProperty("userId") public ObjectId getUserId() { return userId; } @JsonView(Views.Frontend.class) @JsonProperty("userId") public String getUserIdAsString() { return userId.toString(); } This is what I want: View 1: {

JSON deserialization of derived types

空扰寡人 提交于 2020-01-03 01:58:20
问题 class Attribute1 { } class Attribute2 : Attribute1 { } class class1 { Attribute1 attr1; } class class2 : class1 { Attribute2 attr2; } var serializerSettings = new JsonSerializerSettings(){TypeNameHandling = TypeNameHandling.Objects}; class2 a = SomeValidObjectoftype Class2; string serializedClass2 = JsonConvert.SerializeObject(a, serializerSettings); var am = JsonConvert.DeserializeObject<Class2>(serializedClass1); All the above are JSON properties and objects. What I am trying to do is

C# XML Deserialization. Read all inner text from node into string property

孤人 提交于 2020-01-02 11:45:11
问题 I am currently trying to modify my classes so that a my text property on my model contains all inner text of a certain node ( text ) node. An example of the xml which is giving me issues is: <component> <section> <title>Reason for Visit</title> <text> <content ID="ID3EZZKACA">No Reason for Visit was given.</content> </text> </section> </component> My goal is for my model's text property to have the following string: "<content ID="ID0EAAKACA">No Reason for Visit was given.</content>" currently