deserialization

BinaryFormatter - Is it possible to deserialize known class without the assembly?

会有一股神秘感。 提交于 2020-01-02 10:22:13
问题 I am currently trying to interoperate with a program that sends data over the network after first formatting it with C#'s BinaryFormatter. It's a dumb idea, and I hate it, but I have to interoperate with it. I know what the type looks like, I know it's exact layout. But I can't add a reference to that specific assembly in my program for various reasons. Given how tightly coupled BinaryFormatter is to the specific type/version, I can't seem to find a way to get it to deserialize despite

Deserializing child nodes outside of parent's namespace using XmlSerializer.Deserialize() in C#

时光怂恿深爱的人放手 提交于 2020-01-02 08:49:09
问题 I have an application that uses namespaces to help deserialize objects stored in XML. The XML namespace is also the C# namespace where the object resides. For example, given the following XML snip: <xml-config xmlns:app="MyAppNS"> <app:Person> <Name>Bill</Name> <Car> <Make>Honda</Make> <Model>Accord</Model> </Car> </app:Person> <app:Person> <Name>Jane</Name> <Car> <Make>VW</Make> <Model>Jetta</Model> </Car> </app:Person> <app:Car> <Make>Audi</Make> <Model>A6</Model> </app:Car> </xml-config>

Serialize deserialize anonymous child JSON properties to model

末鹿安然 提交于 2020-01-02 07:08:32
问题 I have an API I am receiving data from. That API is out of my control on how it is structured, and I need to serialize and deserialize the JSON output to map the data to my model. Everything works well where JSON is nicely formatted with named properties. What can you do where there is no named value and there is just an array of ints and strings? like under locations here is a sample of the JSON: {"id":"2160336","activation_date":"2013-08-01","expiration_date":"2013-08-29","title":"Practice

Serialize deserialize anonymous child JSON properties to model

狂风中的少年 提交于 2020-01-02 07:08:30
问题 I have an API I am receiving data from. That API is out of my control on how it is structured, and I need to serialize and deserialize the JSON output to map the data to my model. Everything works well where JSON is nicely formatted with named properties. What can you do where there is no named value and there is just an array of ints and strings? like under locations here is a sample of the JSON: {"id":"2160336","activation_date":"2013-08-01","expiration_date":"2013-08-29","title":"Practice

Jackson deserialization Unexpected token (END_OBJECT),

為{幸葍}努か 提交于 2020-01-02 06:49:21
问题 I am trying to deserialize a JSON Object into a Java Object using Jackson annotation on one Abstact class "Animal": @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type") @JsonSubTypes({@Type(value = Dog.class, name = "chien"), @Type(value = Cat.class, name= "chat")}) and here is a sample JSON string: { "name": "Chihuahua", "type": { "code": "chien", "description": "Chien mechant" } } The problem is that the property "type" in the JSON object is also

Json.NET: deserialize nested arrays into strongly typed object

ぐ巨炮叔叔 提交于 2020-01-02 04:31:09
问题 I'm writing client application, which should process server responses. Responses are in JSON. I decided to use Json.NET to deserialize them. And I couldn't simplify or modify those responses (on server side). Particular difficulties of this specific JSON response is that different object types is in same array: hash and array of files. So, I would like to deserialize this array straight ahead into strongly typed object, rather than array of objects. I think that it should be possible to

deserialize list of objects using json.net

心已入冬 提交于 2020-01-02 01:37:48
问题 i have this class public class Image { public string url { get; set; } public string url_40px { get; set; } public string url_50px { get; set; } } public class Category { public List<int> ancestor_ids { get; set; } public int parent_id { get; set; } public List<object> children_ids { get; set; } public string nodename { get; set; } public int num_parts { get; set; } public List<Image> images { get; set; } public string __class__ { get; set; } public int id { get; set; } } and i deserialize it

VB.net deserialize JSON with JSON.net

匆匆过客 提交于 2020-01-01 19:52:25
问题 I look for a solution to my problem since 2 weeks without solution. I would like to deserialize JSON with JSON.NET, but noway ... I create class but when i deserialize the object stay empty (Nothing). Here the JSON : {"plannifReponse": {"@competence":"Abonnement","plannifDonnees": {"entry": [ {"key":"2013-8-11T00:00","value": {"creneaux": [ {"@jour":"2013-8-11T00:00","@heure":"09","@minute":"30","nombreRessources":10}, {"@jour":"2013-8-11T00:00","@heure":"10","@minute":"30","nombreRessources"

C# deserializing enums from integers

让人想犯罪 __ 提交于 2020-01-01 08:04:07
问题 Is it possible to deserialize an enum from an int in c#. e.g. If I have the following class: class Employee { public string Name { get; set;} public int EmployeeTypeID { get; set;} } I can easily create this from XML <Employee> <Name>Joe Bloggs</Name> <EmployeeTypeID>1</EmployeeTypeID> </Employee> using something like this: Employee employee = (Employee)new XmlSerializer(typeof(Employee)).Deserialize(XmlReader); With very little work involved, this allows me to use one generic service that I

Deserialize nested XML element into class in C#

泪湿孤枕 提交于 2020-01-01 04:34:06
问题 I have the following XML structure (edited for brevity) which I have no control over. <GetVehicles> <ApplicationArea> <Sender> <Blah></Blah> </Sender> </ApplicationArea> <DataArea> <Error> <Blah></Blah> </Error> <Vehicles> <Vehicle> <Colour>Blue</Colour> <NumOfDoors>3</NumOfDoors> <BodyStyle>Hatchback</BodyStyle> <Vehicle> </Vehicles> </DataArea> </GetVehicles> I have the following Class: [XmlRoot("GetVehicles"), XmlType("Vehicle")] public class Vehicle { public string Colour { get; set; }