serialization

Jackson: XML to Map with List deserialization

不羁的心 提交于 2020-01-20 21:45:30
问题 Is there a way to deserialize the following xml into Map holding List of items using Jackson? <order> <number>12345678</number> <amount>100.10</amount> <items> <item> <itemId>123</itemId> <amount>100.0</amount> <itemName>Item Name1</itemName> </item> <item> <itemId>234</itemId> <amount>200.00</amount> <itemName>Item Name1</itemName> </item> </items> </order> I tried with XmlMapper mapper = new XmlMapper(); LinkedHashMap map = (LinkedHashMap)mapper.readValue(xml, Object.class); and got the

YAML serialization library for C++?

蹲街弑〆低调 提交于 2020-01-20 18:48:08
问题 YAML seems like a great format for configuration files & data binding persistent objects in human-readable form... Is there a C++ library that handles YAML? Does Boost::Serialization have plans for a YAML option? EDIT: I would prefer an OO library. 回答1: A quick search gave me this: yaml-cpp 回答2: Try the YAML component from the BOOST vault serialization library. EDIT 2014 : A recent development, https://groups.google.com/d/msg/boost-devel-archive/mhT7qIh1nsI/uXAuXFAWrxQJ EDIT 2019 : Didn't try

Typescript deserializing json into collection with multiple types

情到浓时终转凉″ 提交于 2020-01-20 08:21:49
问题 I'm using typescript for a project and need to serialize a collection to json, save it to a file and later deserialize that file into a similar collection. The collection looks something like: elements: Array<tool> and my tool interface looks like: export interface tool { name: string; draw(context:any); } and a tool implementation would look like: export class textTool implements tool { name: string; fontSize:number; fontType:string; draw(context:any){ // draws the control... } } I have few

(.Net) suggestions on making a config file for a program?

╄→尐↘猪︶ㄣ 提交于 2020-01-20 04:26:07
问题 I'm not necessarily referring to app.configs, but a custom configuration file that would store my program's state whenever a user hits a "save" button. In my example, it's a UI builder that allows the user to choose which "fields" are to be displayed on the left and right columns in a two-column screen, along with the order of the fields in each column. There's other stuff too, but you get the idea. The user could open any configuration file they've saved and populate the UI builder

JSON deserialize to constructed protected setter array

久未见 提交于 2020-01-19 15:43:09
问题 I use Newtonsoft JSON to serialize/deserialize my objects. One of those contains an array with a protected setter because the constructor build the array itself and only the members are manipulated. This can be serialized without problem but when it comes to deserialization the property it is ignored because it is not public. I tried a custom converter with it is also not called because it is not public. This is a minimized example: public static class TestCoordsDeserialization { private

Best method of saving data

故事扮演 提交于 2020-01-19 05:33:28
问题 I've made a class in which I want to keep track of stats of students. I intend to make a GUI later to manipulate this data. My main question is: what is the best way to save and later retrieve this data? I've read about pickle and JSON, but I don't really get how they work (especially about how they save the data, like in which format and where). 回答1: For persistent data (storing info about students), a database is a good choice. As already mentioned, Python comes shipped with Sqlite3 which

Javascript serialization of DateTime in asp.net is not giving a javascript date object?

半城伤御伤魂 提交于 2020-01-18 21:35:33
问题 When I parse a DateTime to json in .Net it returns a string (i.e. "\/Date(1249335194272)\/" ). How do I make it return a js Date object constructor not wrap in a string? // js server code var dteNow = <%= jsonDateNow %>; // js rendered code var dteNow = "\/Date(1249335477787)\/"; // C# using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.Script.Serialization; using System.Web.UI.WebControls; namespace testing{ public

Javascript serialization of DateTime in asp.net is not giving a javascript date object?

Deadly 提交于 2020-01-18 21:34:49
问题 When I parse a DateTime to json in .Net it returns a string (i.e. "\/Date(1249335194272)\/" ). How do I make it return a js Date object constructor not wrap in a string? // js server code var dteNow = <%= jsonDateNow %>; // js rendered code var dteNow = "\/Date(1249335477787)\/"; // C# using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.Script.Serialization; using System.Web.UI.WebControls; namespace testing{ public

Javascript serialization of DateTime in asp.net is not giving a javascript date object?

喜夏-厌秋 提交于 2020-01-18 21:34:30
问题 When I parse a DateTime to json in .Net it returns a string (i.e. "\/Date(1249335194272)\/" ). How do I make it return a js Date object constructor not wrap in a string? // js server code var dteNow = <%= jsonDateNow %>; // js rendered code var dteNow = "\/Date(1249335477787)\/"; // C# using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.Script.Serialization; using System.Web.UI.WebControls; namespace testing{ public

C# TcpClient: Send serialized objects using separators?

心不动则不痛 提交于 2020-01-18 04:32:08
问题 Based on serialization (mentioned here https://stackoverflow.com/a/7849374/985798) I am trying to reengineer my small tcp application, which was using a string message until now. But I ran into a small problem and I would like to know what solution you'd recommend me to use: If I am trying to send more than one message in a very small interval, they will be merged in the "queue" and the client will receive both messages at the same time, which will end up with a single broken object. In the