deserialization

Deserialize Dictionary<string, T>

我怕爱的太早我们不能终老 提交于 2019-12-11 03:35:32
问题 For example, I have a some classes: class User { int Id {get; set;} string Name {get; set;} } class Venue { int Id {get; set;} string Adress {get; set;} } class Message { string Text {get; set;} int FromId {get; set;} } I take the json from web: [%user% => {id: 1, name: "Alex"}, %user% => {id: 5, name: "John"}] I can parse it : var myObjects = JsonConvert.DeserializeObject<Dictionary<string, User>>(json); But if have a json: [%user% => {id: 1, name: "Alex"}, %venue% => {id: 465, adress:

Parsing JSON returned from the Sitecore Item Web API

∥☆過路亽.° 提交于 2019-12-11 03:16:19
问题 I am having trouble parsing the following JSON object from the Sitecore API: { "statusCode": 200, "result": { "totalCount": 1, "resultCount": 1, "items": [ { "Category": "PAGE", "Database": "web", "DisplayName": "Profile", "HasChildren": false, "Icon": "/temp/IconCache/Network/32x32/earth.png", "ID": "{7F51AD8B-4A8B-4DA5-87A8-374BEB900801}", "Language": "en", "LongID": "/{11111111-1111-1111-1111-111111111111}/{0DE95AE4-41AB-4D01-9EB0-67441B7C2450}/{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}/

java jackson XML - how to ignore outer wrappers when parsing?

こ雲淡風輕ζ 提交于 2019-12-11 03:08:55
问题 The XML response from the API , I want to parse is something like this: <Envelope> <Body> <RESULT> <SUCCESS>TRUE</SUCCESS> <EMAIL>somebody@domain.com</EMAIL> ... more stuff... </RESULT> </Body> </Envelope> I want to get the fields of RESULT into an object. I could create 3 classes, once for the envelope with the body in it, one for the body with the result in it, and one for the result. But, is there a shortcut? E.g. just create an object for the result data like this: @JacksonXmlRootElement

Empty json object instead of null, when no data -> how to deserialize with gson

霸气de小男生 提交于 2019-12-11 02:59:46
问题 I am trying to parse json data with Google's gson library. But the json data doesn't behave well. It does look like this when everything is alright: { "parent": { "child_one": "some String", "child_two": "4711", ... } } child_one should be parsed as String , child_two as int . But sometimes one of the children has no values what results in an empty object instead of null , like this: { "parent": { "child_one": "some String", "child_two": {}, ... } } I have no access to alter the json feed, so

c# xml deserialization to object with colon and hyphen in xsi:type value

拥有回忆 提交于 2019-12-11 02:58:01
问题 I have an issue when I try to deserialize my XML File to an object using the XmlSerializer class. My XML file looks like this: <fx:FIBEX xmlns:fx="http://www.asam.net/xml/fbx" xmlns:ho="http://www.asam.net/xml" xmlns:ethernet="http://www.asam.net/xml/fbx/ethernet" xmlns:it="http://www.asam.net/xml/fbx/it" xmlns:service="http://www.asam.net/xml/fbx/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="" VERSION="4.1.0"> <fx:ELEMENTS> <fx:CLUSTERS> <fx:CLUSTER xsi

Query on Java Serialization

痞子三分冷 提交于 2019-12-11 02:54:41
问题 I am facing below issue, after adding new member methods in existing class Response implements Serializable{} . There is no explicit serial version id declared. On multiple try, am getting the same serial numbers. Error communicating with the webserver: com.abc.xyz.app.util.common.Response; local class incompatible: stream classdesc serialversionUID = -3900355805473150430, local class serialversionUID = -6706527232726476603 After going through some documentation, i tried modifying the class

SpringMVC @JsonDeserialize doesn't work

a 夏天 提交于 2019-12-11 02:44:39
问题 I got a very simple POJO like below: @Entity @Table(name = "people") public class People(){ @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer peopleId; private Date birthday; @JsonDeserialize(using = DateDeserializer.class) public void setBirthday(Date birthday){ this.birthday = birthday; } } DateDeserializer : public class DateDeserializer extends JsonDeserializer<Date> { @Override public Date deserialize(JsonParser jsonParser, DeserializationContext

Kafka AVRO - conversion from long to datetime

妖精的绣舞 提交于 2019-12-11 02:29:14
问题 I get the following error when I want to send an AVRO message which contains a field that has the type long: Caused by: org.apache.kafka.common.errors.SerializationException: Error deserializing Avro message for id 61 Caused by: java.lang.ClassCastException: java.lang.Long cannot be cast to org.joda.time.DateTime I use Confluent 3.2.0 and Apache Spark 2.2.0. This error is thrown in a Spark Job which processes AVRO messages and prints them in a console. In the AVRO schema, the corresponding

Deserialize XML string to complex type

北城余情 提交于 2019-12-11 02:23:20
问题 My Xml (which I can't change): <result> <type>MAZDA</type> <make>RX-8</type> <country>JAPAN</country> </result> My model: [Serializable, XmlRoot("result")] public class VehicleDetails { public string Type { get; set; } public string Make { get; set; } public string Country { get; set; } } de-serializing this XML works as expected but I want to change the Country property to a complex type, like so: public Country Country { get; set; } and put the country name, "JAPAN", in the Country.Name

deserialize json into .net object using json.net

百般思念 提交于 2019-12-11 02:19:32
问题 I am having a problem deserializing some JSON string back into .net objects. I have a container class which contains some information from external and there is a field call ClassType which defined what type of information is that and the actual content is in another property, which currently can be anything, so we define that as an Object type. Following are the .net class definition which helps to understand the issue. class ClassOne { public string Name { get; set; } public int Age { get;