deserialization

Json Deserialization to a class

谁说胖子不能爱 提交于 2019-12-11 04:52:50
问题 I have dynamic json result and i want to create an object for that json string. After that i will fill that object with the deserialized object. Here is the json string: [{"_34":{ "Id":"34", "Z":["42b23718-bbb8-416e-9241-538ff54c28c9","c25ef97a-89a5-4ed7-89c7-9c6a17c2413b"], "C":[] } }] How does the object look like? Or how can i deserialize this string to a class. Thanks. 回答1: You can use the JavaScriptSerializer which available out of the box or json.net if you prefer something open source.

Entity object's navigation property set to null after Deserialization

妖精的绣舞 提交于 2019-12-11 04:35:15
问题 I am working on a WPF application, the architect is WPF->WCF->DAL the issue is when i call the WCF method, it returns the object. Everything upto WCF level works just fine, but while returning the object, after WCF my navigation properties are setting to null. i am returning the object(POCO) object of Department class, and its navigation property is Employees. I verfied the [DataMember] attribute, this is not the case. But as soon as it reaches the MainUI its Employees property is setting to

Change the path / class name of a serialized Java object after refactoring

亡梦爱人 提交于 2019-12-11 04:11:04
问题 I've launched an app that saves its state with serialized object myfirstpath.UserState. Now for I want to change the path of this object to mycleanpath.UserState (same object, only the path changes). This will work for new users installing the app for the first time but for users updating the app, they will lose their state. Is there a way to load the serialized obect myfirstpath.UserState into mycleanpath.UserState ? (without keeping myfirstpath.UserState in my source code of course). 回答1: I

XmlException: Document element did not appear - line 1, position 1

浪尽此生 提交于 2019-12-11 04:09:16
问题 I'm tring to deserialize a xml string, but for some reason I'm getting the error stated in the title. This is the code I'm deserializing from: public void recieveObject<T>(ref T t){ XmlSerializer xs = new XmlSerializer(typeof(T)); Debug.Log("Waiting for client"); byte[] recievedData = udpc.Receive(ref recieveFromEndPoint); if(recievedData.Length > 0){ string xmlStr = System.Text.Encoding.UTF8.GetString(recievedData, 0, recievedData.Length); //xmlStr = xmlStr.Replace("\r","").Replace("\n", "")

How to deserialize JSON with GSON into corresponding generic Java types?

百般思念 提交于 2019-12-11 04:06:50
问题 I want to deserialize a JSON object (using GSON, because I already use it for searializing objects) to a general Map of type Map<String, Object> . It should create Objects of types that do correspond to the according JSON types, i.e. this JSON Object { "docID" : "a12345", "relation" : ["1", "2", "3"], "title" : { "de" : "German Title", "en" : "English Title"} } should be deserialized in a Map<String, Object> with entries of the following types: ( String , String ), ( String , List<String> ),

Ignore Property to be (XML) serialized

时光毁灭记忆、已成空白 提交于 2019-12-11 03:58:00
问题 My class has some properties that I don't want to be (XML) serialized. Example: public class MyClass { private TimeSpan executionTime = TimeSpan.FromSeconds(0.0); public TimeSpan ExecutionTime { get {return executionTime;} set {executionTime = value;} } public double ExecutionTimeSeconds { get {return executionTime.TotalSeconds;} set {executionTime = TimeSpan.FromSeconds(value);} } } Apart from that this is a bit of useless code, You don't want both methods to be (de)serialized. This problem

Cannot serialize member <x> because it is an interface

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 03:49:46
问题 Follow on question from Error with explicit conversion when using CollectAs<> Code from WebMethod return client.Cypher .Match("(person:Person)") .Where((Person person) => person.Email == username) .OptionalMatch("(person)-[:SPEAKS]-(language:Language)") .OptionalMatch("(person)-[:CURRENT_LOCATION]-(country:Country)" .Return((person, language, country) => new ProfileObject { Person = person.As<Person>(), Language = language.CollectAs<Language>(), Country = country.CollectAs<Country>() })

deserializing json using jackson with missing fields

主宰稳场 提交于 2019-12-11 03:49:36
问题 I am trying to deserialize this JSON using Jackson and I'm having trouble with the array part which as you can see has no field names. What would the java code need to look like to deserialize this? { "foo":[ [ "11.25", "0.88" ], [ "11.49", "0.78976802" ] ], "bar":[ [ "10.0", "0.869" ], [ "9.544503", "0.00546545" ], [ "9.5", "0.14146579" ] ] } Thanks, bc 回答1: The closest mapping (without any more context) would be to make foo and bar each an array of double arrays (2-dimensional arrays).

How to customize deserializer for third party Enum?

丶灬走出姿态 提交于 2019-12-11 03:49:26
问题 I have the following deseriailzer: public class HttpStatusDeserializer extends JsonDeserializer<HttpStatus> { @Override public HttpStatus deserialize(JsonParser jsonParser, DeserializationContext ctxt) throws IOException, JsonProcessingException { ObjectCodec oc = jsonParser.getCodec(); JsonNode node = oc.readTree(jsonParser); return HttpStatus.valueOf(node.asText()); } } and register it public class CustomDeserializerModifier extends BeanDeserializerModifier { @Override public

How to serialize and deserialize a class with byte array as a member in c#

戏子无情 提交于 2019-12-11 03:39:49
问题 I am trying to send data between 2 process in the form of byte streams, which is working fine for almost all the classes but one problem i am having is that the deserilization fails if the class of the object has a byte array inside it and gives me an error stating the assembly where the serilization took place cannot be loaded. I cannot include the assembly in here because both sender and receiver are different applications. Is there a way to fix this? Edit: Sorry it turns out that even