deserialization

Xml Deserialization to Class Error

99封情书 提交于 2019-12-12 00:42:58
问题 I'm trying to deserialize this xml string response to a class: <?xml version="1.0" encoding="UTF-8"?> <result command="searchhotels" tID="1463758732000001" ip="70.112.14.31" date="2016-05-20 15:39:00" version="2.0" elapsedTime="8.5034000873566"> <currencyShort>USD</currencyShort> <hotels count="6"> <hotel runno="0" preferred="no" cityname="DUBAI" order="3" hotelid="856915"> <from>5549.2769 <formatted>5,549.28</formatted> </from> <fromMinimumSelling>6975 <formatted>6,975.00</formatted> <

Serialize and deserialize ActiveRecord model with children

假装没事ソ 提交于 2019-12-11 23:03:55
问题 Form has many entries. To serialize form and it's entries I use: json = @form.to_json( { :only => Form.accessible_attributes.to_a, :include => {:entries => {:only => Entry.accessible_attributes.to_a}}}) Form and entries attributes can be modified or deleted while they are in JSON. To deserialize I use (but not working) : @form = @form.from_json(json) @form.save How to save entries at once with form? 回答1: Had to change entries to entries_attributes: json = @form.to_json( { :only => Form

Deserialise XML response from server

那年仲夏 提交于 2019-12-11 22:04:54
问题 I want to deserialise an object. I saw the following code in msdn.com: private void DeserializeObject(string filename) { Debug.WriteLine("Reading with XmlReader"); // Create an instance of the XmlSerializer specifying type and namespace. XmlSerializer serializer = new XmlSerializer(typeof(User)); // A FileStream is needed to read the XML document. FileStream fs = new FileStream(filename, FileMode.Open); XmlReader reader = XmlReader.Create(filename); // Declare an object variable of the type

Java SerialIzation: 'ClassNotFoundException' when deserializing an Object

岁酱吖の 提交于 2019-12-11 19:20:54
问题 The error: java.lang.ClassNotFoundException: testprocedure.tp$3 at java.net.URLClassLoader$1.run(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang

Subscribing over TCP, deserializing each recieved JSON line

早过忘川 提交于 2019-12-11 19:13:07
问题 tcp_connection = tcp_connect('localhost', 20060) // the server will always send responses on one line. tcp_connection.on('line', function (line) { json = json.decode(line) if(json.result == "success") { // etc, etc, etc. } }) tcp_connection.write("/api/subscribe?source={sourceName}&key={key}&show_previous={true|false}") //stream API request Well, this is a pseudocode I got, and I have no idea how to rewrite it in C#. I got something like this: TcpClient connection = new TcpClientWithTimeout

How do I correctly deserialize .NET Dictionaries using Jackson?

五迷三道 提交于 2019-12-11 19:04:22
问题 to sum it up before the wall of text below :-) I need help with how to deserialize a Dictionary using Jackson and a custom deserializer. Right now I have an Android app communication with a .NET (C#) server. They use JSON to communicate. On the JAVA-side, I am using Jackson to handle the JSON and on the .NET-side I am using the built in DataContractSerializer (I know, ppl will start commenting I should use something else, but Im not so... ;-) ) The problem is that I am sending Dictionaries

File deserialization with ServiceStack's TypeSerializer

佐手、 提交于 2019-12-11 19:04:19
问题 I use ServiceStack.Text as JSON library in my C# project and I'm trying to deserialize a string from file using it's TypeSerializer.DeserializeFromString . I have the following code: async public static void TryLoad(Action<JsonArrayObjects> Ok, Action<string> Fail, string key, int offset) { try { var folder = ApplicationData.Current.LocalFolder; var stream = await folder.OpenStreamForReadAsync(key); var result = await new StreamReader(stream).ReadToEndAsync(); Debug.WriteLine(result); var

Serialization and deserialization of two dimensional float array in C++

若如初见. 提交于 2019-12-11 18:54:29
问题 I have a structure: struct Desc { int rows; int cols; } and two dimensional float array. I need to transfer the structure and data through the network. How to serialize/deserialize it correctly? This is what I do now: Desc desc; desc.rows = 32; desc.cols = 1024; float data[rows][cols]; // setting values on array char buffer[sizeof(Desc)+sizeof(float)*desc.rows*desc.probes]; memcpy(&buffer[0], &desc, sizeof(Desc)); // copying struct into the buffer memcpy(&buffer[0]+sizeof(Desc), &data, sizeof

c# XML deserialization of 1 XML to different classes

倖福魔咒の 提交于 2019-12-11 18:31:26
问题 I would like to manage multiple customer standards efficiently. If I open (deserialize) an XML, I want to determine which classes are used during deserialisation. Choosing another class basically means looking at the XML from an other perspective (view). What I have right now: I have a class Project which has some properties and methods. I am able to serialize instances of motor to XML, this works fine. Also deserialization works fine. Now I create a new class ProjectCustomerA , which is

Deserializing a many-to-one relation with FlexJSON

和自甴很熟 提交于 2019-12-11 18:27:13
问题 I am adding RESTful support to my web application (with Spring) so I can do CRUD operations like this: Read info about a participant (JSONSerialize): $ curl -i -H "Accept: application/json" http://localhost:8080/dancingwithstars/participant/1 { "birthDate": "2013-01-23", "code": "JS0001", "firstName": "Julia", "mainFunction": { "code": "AA" "name": "Principal Dancer" }, "gender": "F", "height": 160.00, "id": 1, "lastName": "Smith", "version": 1, "weight": 55.00 } Or create a new participant