deserialization

Deserialize JSON not working with JSON.NET

放肆的年华 提交于 2020-01-13 10:08:41
问题 I have a problem with the following JSON when deserializing using JSON.NET. { "?xml": { "@version": "1.0", "@encoding": "utf-8" }, "Persons": { "Person": [{ "@Id": "1", "@Name": "John", "@Surname": "Smith" }, { "@Id": "2", "@Name": "John", "@Surname": "Smith", "Skills": { "Skill": [{ "@Id": "1", "@Name": "Developer" }, { "@Id": "2", "@Name": "Tester" }] } }] } } I'm using the following classes: public class RootObject { public Xml xml { get; set; } public Persons Persons { get; set; } }

Deserialize JSON not working with JSON.NET

99封情书 提交于 2020-01-13 10:06:50
问题 I have a problem with the following JSON when deserializing using JSON.NET. { "?xml": { "@version": "1.0", "@encoding": "utf-8" }, "Persons": { "Person": [{ "@Id": "1", "@Name": "John", "@Surname": "Smith" }, { "@Id": "2", "@Name": "John", "@Surname": "Smith", "Skills": { "Skill": [{ "@Id": "1", "@Name": "Developer" }, { "@Id": "2", "@Name": "Tester" }] } }] } } I'm using the following classes: public class RootObject { public Xml xml { get; set; } public Persons Persons { get; set; } }

Deserialize JSON not working with JSON.NET

a 夏天 提交于 2020-01-13 10:06:36
问题 I have a problem with the following JSON when deserializing using JSON.NET. { "?xml": { "@version": "1.0", "@encoding": "utf-8" }, "Persons": { "Person": [{ "@Id": "1", "@Name": "John", "@Surname": "Smith" }, { "@Id": "2", "@Name": "John", "@Surname": "Smith", "Skills": { "Skill": [{ "@Id": "1", "@Name": "Developer" }, { "@Id": "2", "@Name": "Tester" }] } }] } } I'm using the following classes: public class RootObject { public Xml xml { get; set; } public Persons Persons { get; set; } }

ProtoBuf-Net error message “ Invalid field in source data: 0”

我是研究僧i 提交于 2020-01-13 05:45:41
问题 I succeed in serializing instances of the following class but when I try to deserialize right after I get the following error message: " Invalid field in source data: 0" . I have no clue what it refers to because I find below class straight forward. I just updated protobuf-net version to 2.00.614 (runtime version: 2.0.50727). Any idea whether I am possibly overlooking something trivial? [ProtoContract] public class TimeSeriesProperties { [ProtoMember(1)] public string TimeSeriesName { get;

How Deserialization works?

有些话、适合烂在心里 提交于 2020-01-12 05:32:10
问题 As far as my understanding goes constructor of class whose Object is serialized is not called but the no-arg constructor of 1st non serializable constructor. Now consider following code public class SerializeDemo implements Serializable { private String name; int age; //default 0 public SerializeDemo(String name, boolean setAge){ this.name = name; if(setAge){ this.age = 18; } } @Override public String toString() { return "Name is " + name + " and age is " + age; } public static void main

Deserialize JSON into data table in VB.NET using JsonConvert

天大地大妈咪最大 提交于 2020-01-11 13:19:56
问题 I am deserializing JSON into a data table using the below statement in VB.NET. Dim _dt As DataTable = JsonConvert.DeserializeObject(Of DataTable)(myRecords) myRecords is a JSON string. It is working fine, but myRecords has some number properties like {"PhoneNo":"123456789", "ID":"46541"} and after deserialization those properties are converted to a column with data type as string. How can I deserialize them into a number? myRecords is getting dynamically populated, so I can't hard code. 回答1:

Deserialize json array in vb.net

允我心安 提交于 2020-01-11 10:35:09
问题 I have a json array which is formatted as follows: [ { "property":96, "listofstuff":[ { "anotherproperty":"some text here", "yetanother":"text goes here too" } ], "lastproperty":3001 }, <rest of array> ] How can I deserialize this in such a way that I can have a list of objects indexed by property ? Meaning, I want to be able to access the data like this: MyList(96).lastproperty or MyList(96).listofstuff.yetanother and have it return the proper datatype too? Is that even possible in vb.net?

Extract Json values as Map with lift-json

左心房为你撑大大i 提交于 2020-01-11 05:14:09
问题 The documentation for lift-json suggests that I should be able to call 'values' to get my current JObject structure as a vanilla Scala Map. This approach is not working for me, as the return type of 'values' is json.Values rather than a Map as the examples show. What am I doing wrong? Is there an implicit import necessary to accomplish this conversion? scala> val json = parse("""{"k1":"v1","k2":"v2"}""") json: net.liftweb.json.package.JValue = JObject(List(JField(k1,JString(v1)), JField(k2

Golang serialize and deserialize back

限于喜欢 提交于 2020-01-10 07:20:10
问题 What's the best way (completeness and performance) in Golang to serialize and deserialize a struct to string and vice versa? for example, if I have this struct: struct Session { Properties map[string]interface{} Permissions []int64 } I want to store it on Redis and fetch it back. I have tried to save, int and string, it's fine, but how to store struct object? conn := redisConnectors.Get() // set example _, err := conn.Do(`SETEX`, `uid_key`, EXPIRE_SEC, user_id) _, err = conn.Do(`SETEX`,

Serialize PHP => Unserialize JAVA / Serialize for php in string format

南楼画角 提交于 2020-01-10 04:33:06
问题 I have an array in php of this format: <?php $value = array("id" => 42, "user" => "superman"); echo serialize($value); ?> Serialized : a:2:{s:2:"id";i:42;s:4:"user";s:8:"superman";} I receive this into a String in java. How I can do for deserialize this in java ? I know the implements Serializable in java but not work in this case. I want to create an object in this kind of format : import java.io.Serializable; public class Serial implements Serializable{ private int mId; private String mUser