FAQ Database Discussion Community


Deserialize string in generic method c#

c#,deserialization,generic-method
I need deserialize a string with a special encode in a class, like the funcion "JsonConvert.DeserializeObject<>" of NewtonSoft library, I wrote this code: public void getMembersInfo() { Dictionary<String, String> dict = new Dictionary<String, String>(); dict.Add("name", "Name Test"); dict.Add("address", "Addss Test"); Members test = DeserializeObject<Members>(dict); Console.WriteLine("Var Name: " + test.name); }...

deserialize and constructor relationship

c#,xml,deserialization
I don't know why i can't find an easy quick lookup for this on the web but i was wondering what the relationship is between Deserializing an XML representation of an object and the constructor for that object? I am assuming it uses the Default Constructor. And if that's the...

Serialization, Desiarilazation in Swift to JSON

ios,json,swift,serialization,deserialization
So, I've been reading a boatload of material on this topic for several days already. I've solved most of my problems except few. These are the following: 1)How do you serialize Dictionary of Custom classes to JSON,(considering that each class is serializable) 2) How to deserialize JSON, which is a...

How to deserialise json data from the World of Warcraft auction API using Json.NET

c#,json,json.net,deserialization,world-of-warcraft
Here is an example snippet of the json data that the API returns: { "realm":{"name":"Molten Core","slug":"molten-core"}, "auctions":{"auctions":[ {"auc":1880591075,"item":109128,"owner":"Leagra","ownerRealm":"Azjol-Nerub","bid":858600,"buyout":900000,"quantity":100,"timeLeft":"VERY_LONG","rand":0,"seed":0,"context":0}, {"auc":1879726534,"item":43115,"owner":"Nêwt","ownerRealm":"Azjol-Nerub","bid":5120000,"buyout":5120000,"quantity":16,"timeLeft":"VERY_LONG","rand":0,"seed":835268864,"context":0}]} } (Though...

Reading skipped children in Jackson Custom Deserializer

java,json,jackson,deserialization,jackson-modules
I have a deserializer for a specific class which needs some ordering while reading fields. Let's say I have two fields in my class (field1 and field2) and in order to read field2, it first needs field1. For example for the following json data it works because when the deserializer...

Deserializing or parse XML response in Symfony2

php,xml,symfony2,deserialization,jmsserializerbundle
I am calling a API method through cURL and I got this response: <?xml version="1.0" encoding="UTF-8"?> <jobInfo xmlns="http://www.force.com/2009/06/asyncapi/dataload"> <id>75080000002s5siAAA</id> <operation>query</operation> <object>User</object> <createdById>00580000008ReolAAC</createdById> <createdDate>2015-06-23T13:03:01.000Z</createdDate> <systemModstamp>2015-06-23T13:03:01.000Z</systemModstamp> <state>Open</state>...

Loading data from Retrofit issue: Expected BEGIN_ARRAY but was BEGIN_OBJECT

java,android,json,deserialization,retrofit
First, the JSON I'm getting from the server: { "actor": [ { "uid": "/actor-12461615214214348149", "subtype": "some type", "location": { "lat": 38.931, "lng": -77.21 }, "prop1": 100, "prop2": 1, "prop3": 20, "prop4": 80 }, { "uid": "/actor-13893903348679219933", "subtype": "some type", "location": { "lat": 38.93, "lng": -77.21 }, "prop1": 100, "prop2": 1,...

Why does the DeserializeXmlNode output XML enclose array elements in an extra tag?

json,xml,json.net,deserialization
I have the following JSON I am converting to XML: { "root": { "object": [{ "Name": "Cust1", "addresses": [ [{ "AddressLine1": "Address1", "AddressLine2": "Address2" }], [{ "AddressLine1": "Address3", "AddressLine2": "Address4" }] ] }, { "Name": "Cust2", "addresses": [ [{ "AddressLine1": "Address1_2", "AddressLine2": "Address2_2" }], [{ "AddressLine1": "Address3_2", "AddressLine2": "Address4_2" }]...

“no suitable constructor” error when deserializing JSON children

java,json,jackson,deserialization,fasterxml
I'm trying to map a json structure to a pojo using fasterxml/jackson. My json comes from a file and looks like this: { "groups": [ { "name": "Group1", "icon": "group1.png", "banner": "banner.png" }, { "name": "Group2", "icon": "group2.png", "banner": "banner.png" } ], "ticker": [ { "title": "ticker1", "description": "description", "url":...

Why can't I unwrap the root node and deserialize an array of objects?

java,json,jackson,deserialization,json-deserialization
Why am I not able to deserialize an array of objects by unwrapping the root node? import java.io.IOException; import java.util.Arrays; import java.util.List; import org.codehaus.jackson.map.DeserializationConfig; import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.annotate.JsonRootName; import org.junit.Assert; import org.junit.Test; public class RootNodeTest extends Assert { @JsonRootName("customers") public static class Customer { public String email; } @Test public...

deserialize an array json c#

c#,json,deserialization
Please help me, I'm new on working with C# and JSON. I am trying to deserialize json data in c# using newtonsoft namespace. Here are my classes: class lastResponse { public string type { get; set; } public Metadata metadata { get; set; } // public string[] course { get;...

XML deserialization not loading values into class

xml,c#-4.0,deserialization
I have the following XML for which I auto-generated a class. Once the class was generated, I had to make some adjustments to get the PayrollEmployeePayrollDate and PayrollEmployeePayrollCategoryWorkCode classes. Since I made the adjustments, both classes are loaded but all the values are null. I don't get any error unless...

how can i deserialize xml in C#

c#,serialization,xml-serialization,deserialization,xml-deserialization
My code: using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Xml.Serialization; using System.Xml; using System.Xml.Linq; using System.Threading.Tasks; namespace PlaylistEditor.Writers { public class XMLPlaylistWriter : IPlaylistWriter { public void Save(Playlist ply, string filePath) { StreamWriter writer = null; try { XmlSerializer xs = new XmlSerializer(ply.GetType()); writer = new...

How to serialize/deserialize with DataOutputStream and DataInputStream?

java,serialization,deserialization,datainputstream,dataoutputstream
I'm trying to serialize/deserialize things with DataOutputSteam and DataInputSteam instead of ObjectInputStream/ObjectOutputStream. The serialization fails. The txt file remains empty. Of course, the test2 strings are all empty in the end (can't deserialized an empty file). Here is my object : public class Test implements Serializable { public String[] nom;...

How to prevent BSON deserialization instantiating members in a class?

deserialization,mongodb-csharp,bson
I have a class that instantiates it's own internal objects and changes internal properties on them which aren't serialized. One for example is setting the parent object. How do you prevent the BSON driver from instantiating these particular members on a class, since the main class for the document already...

GSON - Deserialize primitive array

java,json,gson,deserialization
Consider this simple Json: { "test": [ 0, 3 ] } Now I want to deserialize it in a simple int array so for that I use a custom deserializer: class ArrayDeserializer implements JsonDeserializer<int[]> { @Override public int[] deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { return context.deserialize(json.getAsJsonObject().getAsJsonArray("test"), int[].class);...

Need help to understand deserialization with ArrayList in Java

java,serialization,arraylist,casting,deserialization
I want write an ArrayList to a file and then read it back again. The list is going to hold Integer objects. Serialization seems to be working fine but I'm having trouble deserilaizing. More specifically I can'get the casting right. The serialization: ObjectOutputStream ou = new ObjectOutputStream(new FileOutputStream(new File("load.dat"))); ArrayList<Integer>...

Deserialize DataTable to custom class using XmlSerializer

c#,datatable,deserialization,xmlserializer
Is it possible to deserialize DataTable to custom Class? One of soap requests return DataTable in this format <xs:schema xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="NewDataSet"> <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:MainDataTable="geolocation" msdata:UseCurrentLocale="true"> <xs:complexType> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element name="geolocation"> <xs:complexType> <xs:sequence>...

Json deserializer

c#,json.net,deserialization
im currently making my first steep with json and well im complety confused. I found many examples how to deserialize json files but nothing helps me. { "102": { "id": 102, "name": "cvmember3", "profileIconId": 28, "revisionDate": 1373593599000, "summonerLevel": 1 }, "101": { "id": 101, "name": "IS1ec76a704e9b52", "profileIconId": -1, "revisionDate": 1355466175000,...

Newtonsoft Json Deserialize Dictionary as Key/Value list from DataContractJsonSerializer

c#,json,dictionary,json.net,deserialization
I have a dictionary serialized to storage with DataContractJsonSerializer which I would like to deserialize with Newtonsoft.Json. The DataContractJsonSerializer has serialized the Dictionary to a list of Key/Value pairs: {"Dict":[{"Key":"Key1","Value":"Val1"},{"Key":"Key2","Value":"Val2"}]} Is there any cool options I can give the JsonConvert.DeserializeObject<>() that will make it support both that data format and...

JToken does not deserialise like JsonConvert.DeserializeObject

json,f#,json.net,deserialization,nodatime
I ran into trouble deserialising a NodaTime.Instant with JToken. When using JsonConvert.DeserializeObject the issue does not show up. The following sample code fails with an exception: let jsonOptions = let n = new JsonSerializerSettings() n.ConfigureForNodaTime(NodaTime.DateTimeZoneProviders.Tzdb) JToken.Parse("\"2010-02-12T23:22:00Z\"") .ToObject<Instant>(JsonSerializer.Create(jsonOptions)); The stacktrace of the exception is: deserialisation/deserialisation with JToken: Exception: NodaTime.Utility.InvalidNodaDataException: Unexpected...

How do I desserialize a Path2D.Double object?

java,deserialization,path-2d
I'm trying to save an object that has an ArrayList of Connector, which is a class that extends Path2D.Double. It gives me the exception gui.Connector; no valid constructor. I did a little research and came across this: no valid constructor when serializing a subclass of Path2D.Double It gave me a...

Deserializing a List of a:anyType

c#,xml,deserialization
I have an existing XML file provided by another application, that looks similar to this: <Root xmlns="http://someNameSpace"> <DisplayName>RootName</DisplayName> <Groups> <Group> <Elements> <a:anyType i:type="SomeType"> <DisplayName>ElementName</DisplayName> </a> </Elements> </Group> </Groups> </Root> I'm attempting to write a class that can be deserialized with XmlSerializer, which currently looks like this: public class Root {...

How to handle null in xml and c# -2

c#,xml,wpf,null,deserialization
Let's consider that this was automatically generated xml file and in the second Address tag there is nothing. It is null. If it was not null , we are going to make a list for address and then continue with a class declaration as below. But if we do so,...

Deserializing to a subclass problems

c#,xml,xsd,deserialization,xmlserializer
I have been trying to deserialize some XML into a class which is a subclass of another class. When I tried deserializing into the base class it works. However when the class is deserialized to any of the subclasses it will fail. I would like to know why this is...

XmlSerializer Won't Deserialize over NetworkStream

c#,tcp,deserialization,xmlserializer,networkstream
I'm looking to implement a simple Client/Server setup that can transfer a serialized EmailRequest object (using XmlSerializer) from the client to the server, to be used to send an email. Server class Program { private static void Main() { try { TcpListener listener = new TcpListener(IPAddress.Parse("127.0.0.1"), 8888); listener.Start(); while (true)...

Json deserialization class structure on client

c#,json,deserialization
I am unable to deserialize JSON data on my client end point. It receives JSON data like this: { "WaitForClientMessagesResult": [ { "__type": "KeepAliveMessage:#Data.WebGateway", "MessageId": 1, "Type": 0, "PositionInQueue": -1 } ] } KeepAliveMessage is a derived class of WebResponseMessage. The service returns an IEnumerable<WebResponseMessage>. I'm getting exceptions like this:...

reading data from a serialized file containing multiple objects

java,deserialization
I'm trying to read data from a file containing multiple objects of a class. But I'm getting null pointer exception while adding objects to list. can anyone help? Here's the code: //I'm following the same approach, but getting null Pointer exception while //adding the object to a list. I'll post...

How to write Scala Play framework custom class's multiple JSON serializer deserializer?

json,scala,serialization,playframework,deserialization
I have following class need to serializer deserializer case class User(userId: Int, userName: String, email: String, password: String) { def this() = this(0, "", "", "") def this(userId: Int){ this(userId, "", "", "" ) } def this(userId: Int, userName: String){ this(userId, userName, "", "" ) } def this(userId: Int, userName:...

deserialize json array return null

.net,json,vb.net,serialization,deserialization
well.... trying to deserialize json into a list of "users" but can't make it work. Here' the Json: [{"Aatrox":{"version":"5.2.1","id":"Aatrox","key":"266","name":"Aatrox","title":"the Darkin Blade","blurb":"Aatrox is a legendary warrior, one of only five that remain of an ancient race known as the Darkin. He wields his massive blade with grace and poise, slicing through...

Issue deserializing encrypted data using BinaryFormatter

c#,serialization,deserialization,binaryformatter,cryptostream
Here is my code: public static void Save<T>(T toSerialize, string fileSpec) { BinaryFormatter formatter = new BinaryFormatter(); DESCryptoServiceProvider des = new DESCryptoServiceProvider(); using (FileStream stream = File.Create(fileSpec)) { using (CryptoStream cryptoStream = new CryptoStream(stream, des.CreateEncryptor(key, iv), CryptoStreamMode.Write)) { formatter.Serialize(cryptoStream, toSerialize); cryptoStream.FlushFinalBlock(); } } } public static T Load<T>(string fileSpec) {...

SignalR : use camel case

serialization,json.net,signalr,deserialization
I would like to know if there is a way to configure SignalR so that the client functions in the hub return objects using camel case. Thanks....

WCF Streaming Convert Byte[] to Class Object

c#,wcf,serialization,streaming,deserialization
I have a Streaming WCF service. It receives a stream of a serialized class called ContentObjectData. The bytes I receive in from the stream I have temporarily placed in an ArrayList as I don't know how big the Stream is and to be honest I don't know what to do...

How to check an object deserializable in C#?

c#,.net,deserialization,json-deserialization
i wanna check an object Is Deserializable or not? i want to check a string json can be desirializable or not? For example : if(obj.IsDeserializable()) { var obj1 = new JavaScriptSerializer().Deserialize<object>(CObject); } else { //dosomething ...} How can i do that ? ...

Jackson deserialization with anonymous classes

java,json,serialization,jackson,deserialization
I have been searching all day for something that answers this, but I have not had a lot of luck thus far. My question is straightforward: how do I deserialize an anonymous object correctly using Jackson. private interface Interface1 { int getValue(); } public static void testAnonymousObject() throws IOException {...

Cannot deserialize the current JSON array (e.g. [1,2,3]). C#, cant figure the error out

c#,json,api,serialization,deserialization
I'm trying to retrieve all names from the following json data and put it in a textbox. This is the json data I have shortened some values to make it easier to read but it does not effect the question. [{ "id": "LEA", "name": "Limited Edition Alpha", "block": null, "type":...

Does changing the class name affect Java Deserialization?

java,serialization,deserialization,classname
I am making a modification and a separate application that allows replays to be saved for a certain game. What I have to serialize and deserialize is an 2 arrays of class ContO, arrays of class Plane, Trackers, and a class Medium, and that is no problem. To extend this...

Deserialize multiple XML elements with the same name in C#

c#,xml,deserialization
Im trying to parse this XML response: <?xml version="1.0" encoding="utf-16"?> <CurrentWeather> <Location>BOSTON LOGAN INTERNATIONAL, MA, United States (KBOS) 42-22N 071-01W 54M</Location> <Time>Feb 11, 2015 - 11:54 AM EST / 2015.02.11 1654 UTC</Time> <Wind> from the N (010 degrees) at 17 MPH (15 KT) gusting to 26 MPH (23 KT):0</Wind> <Visibility>...

JAVA Jackson Parsing JSON Response that Contains List/Array

java,android,json,jackson,deserialization
I'm trying to deserialize a JSON string but I keep running into JSON Mapping Exception. I've been scouring the internet but have had little luck. My JSON response that I'm trying to deserialize looks like the following: {    "comments": [{          "id": "fa6491aeb",          "user": {             "userId": "e4dddf5e1",...

How can I deserialize tons of confusing .JSON to a listbox?

c#,json,deserialization
I am working with Json.net to fill ListBox Items with a list of movies (Title, Year, and url to medium-image) from this really long and heavy json code: {(...blabla)"movies":[{"id":4120,"url":"https:\/\/yts.to\/movie\/glee-2009","title":"Glee","year":2009,"medium_cover_image":"https:\/\/s.ynet.io\/assets\/images\/movies\/glee_2009\/medium-cover.jpg","state":"ok",}{(...blabla} Problem is, I have just started working with Json.net and am really confused by what I have to do. I've just...

Retrofit, Gson and an array of heterogeneous objects

android,json,gson,deserialization,retrofit
I'm using Retrofit to perform REST requests to our server. One of these requests return an array of objects that, once deserialized in POJOs, extend from the abstract class Event. Event has the method getEventType() that returns a String, this string is the value for the key "EventType" that I...

how to ignore null when deserializing from json string to object?

java,json,serialization,deserialization
I have a class defined as below: // Ignore all the unknown properties in input JSON @JsonIgnoreProperties(ignoreUnknown = true) // Only include non null values in deserialized Java object. @JsonInclude(value = Include.NON_NULL) public class Person { @JsonProperty("person_id") private String personId; @JsonProperty("school") private String school; @JsonProperty("hobbies") private Map<String, List<AttributeBag>> hobbies =...

Deserialize text in Java data structure

java,deserialization
I would like to eval() the following text: (2, [(3, 4), (5, 6)]) in Java, into some objects I defined, so let's assume: new Pair(1, new ArrayList<Pair>({new Pair(3,4), new Pair(5,6)})) What is the strategy to achieve so? The idea is that I could get any of the following: (2, [(3,...

How to copy by reference and deserialize a list of objects in java?

java,arrays,serialization,reference,deserialization
So I am a beginner in Java and my professor has us doing this assignment and I've been looking around but I can't seem to find the right answer for my type of code. We had to create a class file and then a public class file to test it....

Simple java library to deserialise json to a java object using getters/setter and not properties(GSON)

java,json,deserialization
I am currently working on a REST based application and need to convert a json object to a class. The problem is that class is from a third party library and I do not have access to the source file. Further the properties in the java object does not match...

Not able to deserialize json data into structs

json,struct,go,deserialization
I'm a newbie to go and trying to write a simple app to pull some school data from greatschools.org. The json data looks like this: { "schools": { "school": [ { "gsId": 1, "name": "Catholic School", "type": "private", "gradeRange": "PK-9", "enrollment": 39, "parentRating": 4, "city": "Denver", "state": "CO", "address": "111...

How to covert JSON field name to a Java compatible property name while doing Jackson de-serialisation?

java,json,serialization,jackson,deserialization
I have ServerDetails pojo class. package org.vo; import org.codehaus.jackson.annotate.JsonProperty; public class ServerDetails { private Integer serverId; private String server_url; public ServerDetails() { } public ServerDetails(Integer serverId, String server_url) { this.serverId = serverId; this.server_url = server_url; } @JsonProperty("server-id") public Integer getServerId() { return serverId; } public void setServerId(Integer serverId) { this.serverId...

How to ignore data in JSON.NET that changes between returns

c#,json,deserialization
I'm parsing JSON data return by a third party. I have my class generated with JSON2CSharp which works for the first sample we received. I tweaked it to have some JsonProperty settings so that it doesn't require certain properties that are not always present. Now I received more samples and...

Redis Serialization and Deserialization

redis,deserialization,spring-data,serializable,spring-data-redis
I have noticed that some of my serialized objects stored in Redis have problems deserializing. This typically occurs when I make changes to the object class being stored in Redis. I want to understand the problem so that I can have a clear design for a solution. My question is,...

Deserializing arrays with protostuff

java,json,serialization,deserialization,protostuff
I am trying to use protostuff to serialize deserialize json but when i serialize the object the size of the array is put in front {"id":1,"price":1.2,"name":"alex","tags":{"a":3,"b":["tag1","tag2","tag2"]}} if i trie to desirialize the same string it works like a charm but my data dosent have "a":3,"b": for the tags its just...

Using raw array text as input for array in PHP

php,arrays,wordpress,serialization,deserialization
I need to be able to run some built in PHP functions on a large array which came from a corrupted wordpress database of which I have no backups except for a csv file. Specifically the wp_options table is what is messed up because some of the values in the...

Does Java have builtin ability or standard patterns for static deserialization?

java,deserialization,standards
Serialization makes sense as an instance method - an object might reasonably be able to serialize itself. An object should only ever be in a valid state, and all valid states of an object should be permissible to serialize. There is nothing invalid about this idea. But deserialization does not...

Jackson: How to deserialize json with shorthand property value

java,json,jackson,deserialization
I am struggling to find out how to deserialize following JSON with shorthand conventions into Java POJOs using Jackson. [ { "id":1, "type": "simple" }, { "id":2, "type": { "kind": "simple" } }, { "id":3, "type": { "kind": "complex", "someOtherThing": "value" } } ] The "type" property here can be...

Serializable class with ISerializable constructor

c#,serialization,deserialization,serializable
Is it possible to declare the class [Serializable], and yet add a constructor with the signature (SerializationInfo information, StreamingContext context) to do some specific task at the time of deserialization?

JsonMediaTypeFormatter trying to deserialise a property with IgnoreDataMember attribute

json,deserialization,web-api,circular-reference
I have a JSON string such as: { "$id": "1", "Username": "mrdan", "Email": "[email protected]", "Roles": [ { "$id": "2", "Name": "Super Admin", "Users": [ { "$ref": "1" } ], "Permissions": [ { "$id": "3", "Name": "UserSave", "Roles": [ { "$ref": "2" } ], "Id": "2d9a1268-6e53-4749-89f6-59ec0132e737" }, { "$id": "4", "Name":...

Approaches for populating Java objects from maps

java,xml,serialization,jaxb,deserialization
I'm dealing with a recurring pattern at work. public class SapExample { public static void main(String[] args) { // read SAP data.. // get table List<Map<String, Object>> objects = getTable("ET_WIDGET"); for (Map<String, Object> entry : objects) { Object value = entry.get("WDGT_ID"); String id = (value != null) ? String.valueOf(value) :...

How do I handle an Invalid Stream header Exception: 00000001?

java,serialization,deserialization,objectinputstream
java.io.StreamCorruptedException: invalid stream header: 00000001 Simple Project I found this, and this seems to be a common problem. If you write to a directory with files and then manually deleted one later, you will end up getting this error. java.io.StreamCorruptedException: invalid stream header: 00000001 at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:806) at java.io.ObjectInputStream.<init>(ObjectInputStream.java:299) The code:...

Read nested json objects that have been serialized via gson library

java,json,serialization,gson,deserialization
I am storing an object in shared preferences. To do this I am serializing the object using the gson library and a typeadapter before storing them. Here's what my object looks like in json: { "id": 0, "name": "Sensor 2D:D3:5C", "address": "00:07:80:2D:D3:5C", "device": { "mAddress": "00:07:80:2D:D3:5C" }, "temp": "31342e37" }...

Deserialization to classes created from XSD does not contain all data

c#,xml,xsd,deserialization
I wanted to deserialize TCX files containing sport data into some my local/temporary object. I used XSD schema describing such format and created classes using xsd2code. After that I was able to deserialize XML into proper object and the deserialzator didn't throw any exception. But when I started to expand...

Deserialize Json to Object Exception

c#,json,deserialization,json-deserialization
I have a json string: {"GetOrderListResponse": {"orderListResponse": { "orderDetails": [ {"order": { "orderId":208, "legDetails": { "legNumber":1, "symbolInfo": { "symbol":"CSCO" } } } }, {"order": { "orderId":200, "legDetails": [ { "legNumber":1, "symbolInfo": { "symbol":"IBM" } }, { "legNumber":2, "symbolInfo": { "symbol":"IBM", "callPut":"CALL", "expYear":2010, "expMonth":4, "expDay":17, "strikePrice":115 } } ] } }...

Deserialize an Object with Camel-Netty4

sockets,apache-camel,deserialization,netty,decoder
At the client side I have a working-fine socket sending a Java Object: Detail detail = new Detail(); //client object Socket client = new Socket(host, port); OutputStream out = client.getOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(out); oos.writeObject(detail); oos.flush(); Note: this is the client socket so cannot be changed. At the server...

cast a stream or byte array to object

c#,unity3d,stream,bytearray,deserialization
In our game, to save a "Ghost" (a serializable class which is record of how someone played a level), we use straightforward BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(filePath, FileMode.Open); object ghost = bf.Deserialize(file); file.Close(); return (Ghost)ghost; Which works perfectly, and to save a Ghost, BinaryFormatter bf =...

WCF, XML deserialization

c#,xml,wcf,serialization,deserialization
I have a simple WCF service [ServiceContract] public interface IService1 { [OperationContract] string GetData(ShoppingCart value); } public class ShoppingCart { public string name; [XmlElement("ShoppingCartItem")] public ShoppingCartItem[] ShoppingCartItems; } public class ShoppingCartItem { public string Description; } And a simple test console. When I add my service reference to test console,...

Reading dictionary structure from text file in python

python,dictionary,serialization,deserialization
I have file where I have defined python dictionary: dict = {'Name': 'Zara', 'Age': 7, 'Class': 'First', 'Friends': {'Emil':1, 'Frank':0} }; I want to read this dictionary and use it's element in python code. I've end up with following code: #!/usr/bin/python import sys import os import ast import re from...

How to deserialize a generic type with ObjectMapper Jackson

json,jackson,deserialization,fasterxml,object-object-mapping
I am struggling trying to simplify my code. I have a common oppperation that makes a request to an API and gets a JSON object. This json can be Categories, Products etc. I am using jackson ObjectMapper. Currently I have a method for each request, but I want to simplify...

Deserialize XML Rest WebApi Call?

c#,xml,asp.net-web-api,deserialization
I have been following some online examples and for some reason I cannot successfully deserialize the following XML document: <?xml version="1.0" encoding="UTF-8"?> <result> <postcode>BD1 1LT</postcode> <geo> <lat>53.793063240118215</lat> <lng>-1.7540318423563699</lng> <easting>416300.0</easting> <northing>433000.0</northing> <geohash>http://geohash.org/gcwf00dz21g1</geohash> </geo> <administrative> <council>...

How to deserialize a CoNLL format dependency tree with ClearNLP?

java,nlp,deserialization,parse-tree,clearnlp
Dependency parsing using ClearNLP creates a DEPTree object. I have parsed a large corpus and serialized all the data in CoNLL format (e.g., this ClearNLP page on Google code). But I can't figure out how to deserialize them. ClearNLP provides a DEPTree#toStringCoNLL() method (scroll down this page to see it)....

protoc-c: Nested structure with optional string throws seg fault

c,serialization,deserialization,protocols,protocol-buffers
Trying out Google protocol buffers for my code in C language. messagefile.proto =================== mesage othermessage { optional string otherstring = 1; } message onemessage { optional string messagestring = 1; optional int32 aninteger = 2; optional othermessage otr_message= 3; } ============================================== --> protoc-c messagefile.proto --c_out=./ this resulted in two files...

How to send Java objects that are not defined structures in Thrift

java,serialization,deserialization,thrift
Is there a way to send Java objects that are not defined in thrift files as a structures from one java application to another java application via thrift. The problem is that we are using an external library that has it's own domain model and we need to send those...

reconstruct python method with kwargs with marshal and types?

python,serialization,deserialization,marshalling,unmarshalling
I am using the marshal module to serialize some Python methods, and reconstruct them using types module (Is there an easy way to pickle a python function (or otherwise serialize its code)?). I am having trouble getting it to work with optional kwargs. E.g. import marshal import types def test_func(x,...

How can I retain the type property when deserializing with Jackson's @JsonTypeInfo?

java,json,polymorphism,jackson,deserialization
I have a setup like this: @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "dishName", defaultImpl = Food.class) @JsonSubTypes(value = { @Type(name = "fries", value = Fries.class), @Type(name = "burger", value = Burger.class) }) public class Food { private String dishName; @Override public String toString() { return dishName + ",...

Deserializing public property with non-public setter in json.net

json.net,deserialization
Suppose I have the following class - public class A { public int P1 { get; internal set; } } Using json.net, I am able to serialize the type with P1 property. However, during deserialization, P1 is not set. Without modifying class A, is there an in build way to...

Deserialize array Object using Newtonsoft Json.Net

c#,json,.net-4.0,json.net,deserialization
I have following json string [ { "itemtype": "note", "body": "some text" }, { "itemtype": "list", "items": [ { "item": "some text" }, { "item": "some text" } ] }, { "itemtype": "link", "url": "some link" } ] Which I need to parse in C#. My string might return error...

Error during deserializing XML

c#,xml,serialization,deserialization
Class that I am serializing: public class StyleProperties { [XmlAttribute] public string Name; [XmlAttribute] public string Description; [XmlAttribute] public StyleType Type; public ShapeStyleProperties ShapeStyle; public TextStyleProperties TextStyle; } Part that is responsible for serializing data: XmlSerializer serializer = new XmlSerializer(typeof(StyleProperties)); PPT.Presentation pres = Globals.ThisAddIn.Application.ActivePresentation; CustomXMLParts parts = pres.CustomXMLParts; //var serializer...

How to parse Hashtable / ArrayList [duplicate]

c#,serialization,arraylist,deserialization,hashtable
This question already has an answer here: How to unserialize PHP Serialized array/variable/class and return suitable object in C# 3 answers In the picture you can see what is in ht, but how do i parse the values from ht.. its a php serialization that i deserialize with this...

Deserializing many network messages without using an ad-hoc parser implementation

haskell,deserialization
I have a question pertaining to deserialization. I can envision a solution using Data.Data, Data.Typeable, or with GHC.Generics, but I'm curious if it can be accomplished without generics, SYB, or meta-programming. Problem Description: Given a list of [String] that is known to contain the fields of a locally defined algebraic...

Convert any class to a keyvaluepair

c#,deserialization
I have a number (maybe a lot) of classes that are simple like so public class ResultA { public DateTime Date { get; set; } public int Year { get; set; } public int Month { get; set; } public int Day { get; set; } } public class ResultB...

How to write objects to file and retain it even after the program is closed in Java?

java,swing,object,serialization,deserialization
I am making a Smart ATM project in which a user can create a account as well and thus I will need to store the data to file. I have tried using the Serialization method and writing the objects of User class to the serialized file. But the problem is...

Java: Deserialize a json to object in rest template using “@class” in json -SpringBoot

java,jackson,spring-boot,deserialization,resttemplate
I have to instantiate a class which extends the abstract class from JSON using information in @class as shown below. "name": { "health": "xxx", "animal": { "_class": "com.example.Dog", "height" : "20" "color" : "white" } }, Here the abstract class is animal and dog extends the animal class. So using...

InvalidOperationException deserializing Atom XML

c#,xml,deserialization
I'm using this C# code to read an XML RSS feed and deserialize it against a model: List<RssFeedModel> rssFeedItems = new List<RssFeedModel>(); var url = @"http://mimijumi-dev.myshopify.com/blogs/news.atom"; string result; using (var httpClient = new HttpClient()) { var request = new HttpRequestMessage(HttpMethod.Get, url); var response = await httpClient.SendAsync(request); result = response.Content.ReadAsStringAsync().Result; }...

Deserialize Json - Object of objects

c#,json,json.net,deserialization,json-deserialization
I have some JSON being sent to me that looks like this: {"MessageCodes": { "Code1": "Message 1", "Code2": "Message 2", "Code3": "Message 3", "Code4": "Message 4", "Code5": "Message 5", "Code6": "Message 6", }} This is saying there is an object called MessageCodes which contains many other objects within it (Code1,...

Cannot find a way to Deserialize Json indexed array using Json.Net

c#,json,serialization,json.net,deserialization
I am trying to figure out a way to deserialize Json object of type: { "0": { "course": { name: "<cource name", .... } }, "1": { "course": { name: "<cource name", .... } }, "success": true } into List<Course> where public class Course { public string Name { get;...

JMSSerializerBundle, Deserialize doesn't Relationship After Persist

php,symfony2,doctrine,deserialization,jmsserializerbundle
Deserialization process OneToMany-ManyToOne process always get relation data sets NULL. The Result Entity: @ORM\OneToMany(targetEntity="\Acme\DemoBundle\Entity\AnswerContent", mappedBy="answerResult", cascade={"persist", "remove"}, orphanRemoval=true) @JMS\Type("ArrayCollection<Acme\DemoBundle\Entity\AnswerContent>") @JMS\Groups({"survey_answer_fetching"}) The Answer Entity: @ORM\ManyToOne(targetEntity="Acme\DemoBundle\Entity\AnswerResult", inversedBy="answers") @ORM\JoinColumn(name="answer_result_id",...

Trying to read a serialized file

java,file,arraylist,deserialization
I've been trying to read this file and add each object in an ArrayList. The problem is that it never goes inside the while loop. Do you guys know what could be the problem? And may I improve the syntax of the code? public ArrayList<Notificacion> obtenerListaNovedades() { ObjectInputStream ois =...

Custom deserializer or different class design Retrofit

java,android,gson,deserialization,retrofit
Retrofit makes things so easy for a noob like me. However, the API response structure that I'm requesting for my current project doesn't follow the same format as I have used before. I am unsure of whether I need to rewrite my POJO or make a custom deserializer in GSON....

Deserialize XML with variant child

c#,xml,class,object,deserialization
I have a device that generates 6 different types of XML notifications, via TCP, at random. I am already successfully deserializing the notifications; however, 1 particular notification, event, I need some advice on how to handle it more efficiently. Here are 3/36 examples of the event notifications: Example 1 <event>...

Model to LazyMap

dictionary,groovy,deserialization
How do I convert/deserialize these models public class AccessCredentials { String userName = '' String password = '' LoginOptions loginOptions = new LoginOptions() } public class LoginOptions { String partnerId = '' String applicationId = '' } into a LazyMap like : [ userName : userName, password : password, loginOptions...

Serialisation of an Object Java

java,serialization,deserialization,java-io
I would like to serialise/deserialise an object. Code runs but the result in the txt is crap. Here is the code : public class Test implements Serializable { public String[] nom; public Test() { nom = new String[5]; nom[0] = "Coucou"; nom[1] = "Je suis un tab de String"; nom[2]...

MusixMatch API and GSON: Using track.snippet.get instead of track.lyrics.get

java,json,gson,deserialization
I am working on the final project for an intro to Java class. Part of the project involves getting a lyric snippet from MusixMatch using their API. I am able to get lyrics from the API using track.lyrics.get, but cannot get snippets using tracks.snippet.get. I started with a Java wrapper...

Deserialize Json arrays and simple object

c#,arrays,json,deserialization
I´m deserializing a JSON response and there is a object that could be an array or a simple object, for example: { "ValueAdds":{ "@size":3, "ValueAdd":[ { "description":"desc 1" }, { "description":"desc 1" } ] } } and the other case: { "ValueAdds": { "@size": "1", "ValueAdd": { "description": "Internet inalámbrico...

Deserializing JSON search results into strongly typed lists (JSON.NET)

c#,json,json.net,deserialization
I have search results in JSON and I want to deserialize it into strongly typed objects For example: { searchresult: { resultscount: 15, results: [ { resultnumber: 1, values: [ { key: "bookid", value: 1424 }, { key: "name", value: "C# in depth" }, ] } ] } } And...

How to deserialize a datatable to list

c#,serialization,datatable,deserialization
Im looking for a library(nuget preferably) that converts a datatable with column names matching a generic object, into a list of that object. For example if i have a class: public class foo{ public string bar{get;set;} public int count{get;set;} } And a datatable +---------+-------+ | bar | count | +---------+-------+...

Deserialize with Json.Net fails on some fields

c#,json,json.net,deserialization
I try to deserialze Json into a c# object using Json.Net. c# class: public class Evaluation { [DataMember(Name = "id")] public int Id { get; set; } [DataMember(Name = "avg")] public string Average { get; set; } [DataMember(Name = "median")] public string Median { get; set; } [DataMember(Name = "teacherID")]...

Custom DateTime serialization/deserialization using DataContractJsonSerializer

c#,json,serialization,deserialization
How to change the default JSON DateTime serialization/deserialization to a custom format using DataContractJsonSerializer for all DateTime properties in the object graph? The Json.Net library deals with this but I can't use that in this project. I tried IDataContractSurrogatebut I cannot access the value -> string conversion for DateTimes. The...

Boost: Re-using/clearing text_iarchive for de-serializing data from Asio:receive()

c++,serialization,boost,deserialization,boost-asio
This is my current function that de-serializes data received via Boost:Asio UDP transmission. It works perfectly, however the performance is pretty bad. About 4000 or so calls per second will use ~16% of CPU, which is a full thread of an I7. Running a performance test on the code shows...

Serialization exception using C#

c#,serialization,deserialization
I am new to C# and am trying to write some information to a file. I got the program running properly when I have the Car class in the same .cs file, but when I remove this class into another .cs file in the project, I get the runtime error...

Override Json deserializing a number with a leading zero as a decimal and not an octal value

c#,json,serialization,json.net,deserialization
I am generating a json object, { "number":0100 } When this object is deserialized in C# using Newtonsoft.Json, 0100 is treated as an octal number because of the leading zero. Is there a way to override this functionality and make it consider the number as a decimal integer?...

Deserializing JSON to flattened class

json,json.net,deserialization
I found the same question here... Deserializing nested JSON structure to a flattened class with Json.NET using annotations ...but without a proper answer. One of the best suggestion is to wrap the nested object in a new class but this approach introduces another issue: lego name. In my example the...