serialization

JAXB - Parse element into string

帅比萌擦擦* 提交于 2020-01-16 04:33:08
问题 Is there a way to parse part of an XML message into a String keeping it in XML format? Example... <person> <name>John Doe</name> <age>24</age> <address> <street>bailey</street> <city>boston</city> </address> </person> public class Person { @XmlElement private NameClass name; @XmlElement private int age; @XmlElement private String address; ... } public class NameClass { ... } Where I want the entire address element to be kept in XML format and parsed as a String. 回答1: You can use

Deserialize Json into object of type T returns 0

寵の児 提交于 2020-01-16 04:14:08
问题 I'm trying to deserialize the JSON response to List, it always returns 0. Please look at the code below and suggest the fix. JSON Data:- tripSeats = {"seats":[ {"available":"true","baseFare":"600","serviceTaxAbsolute":"0"}, {"available":"true","baseFare":"600","serviceTaxAbsolute":"0"} ]} My Classes:- public class Seat { public string available { get; set; } public string baseFare { get; set; } public string serviceTaxAbsolute { get; set; } } public class Seats { public List<Seat> seats { get

Combination of Boost ICL and Boost Serialization

雨燕双飞 提交于 2020-01-16 04:13:29
问题 I'm trying to use the Boost Serialization library to archive Boost ICL interval sets (because I couldn't find any other more or less standard ways to serialize them). I want to split the serialize function into two functions save and load . Sorry to say, I'm stuck in the load function for now - I can't save even the size of the interval set. My testing program is below. The compiler complains about the line A << IS.iterative_size() , which is strange cause the return type of the iterative

How can I unserialize this string?

℡╲_俬逩灬. 提交于 2020-01-16 01:21:14
问题 I have this string in serialize format a:6:{s:5:"width";i:452;s:6:"height";i:336;s:14:"hwstring_small";s:23:"height='96' width='128'";s:4:"file";s:20:"2012/01/Picture3_410_1325761656.jpg";s:5:"sizes";a:8:{s:9:"thumbnail";a:3:{s:4:"file";s:35:"Picture3_410_1325761656-162x160.jpg";s:5:"width";i:162;s:6:"height";i:160;}s:6:"medium";a:3:{s:4:"file";s:35:"Picture3_410_1325761656-258x191.jpg";s:5:"width";i:258;s:6:"height";i:191;}s:8:"post-top";a:3:{s:4:"file";s:35:"Picture3_410_1325761656-110x110

Custom JSON representation of query result

此生再无相见时 提交于 2020-01-15 20:59:25
问题 I'm looking for the place in Django REST Framework to hook in when wanting to format the result of a query in a specific way. That is, I want to take all the rows returned by a query and create a very specific type of JSON response with some meta data and a different (nested) structure. It seems that serializers take care of one row at a time. Are custom views the right place for this? 回答1: I hope this helps... (Django 1.8) Model: class Users(AbstractBaseUser): email = models.EmailField

DeSerialization doesn't work though i Implement GetObjectData method and Constructor

China☆狼群 提交于 2020-01-15 12:06:32
问题 I have a static generic dictionary in a class. As static memeber cannot serialized so i have implented ISerializable interface and method GetObjectData to serialize. I have a constructor which will also accept SerializationInfo and StreamingContext to deserliaze the dictionay. Now when i try to serialize and deserialize , it always return 1(thoug i added 2 entries). please find the pseduo code- [Serializable] public class MyClass : ISerializable { internal static Dictionary<long, string> dict

DeSerialization doesn't work though i Implement GetObjectData method and Constructor

谁说胖子不能爱 提交于 2020-01-15 12:06:04
问题 I have a static generic dictionary in a class. As static memeber cannot serialized so i have implented ISerializable interface and method GetObjectData to serialize. I have a constructor which will also accept SerializationInfo and StreamingContext to deserliaze the dictionay. Now when i try to serialize and deserialize , it always return 1(thoug i added 2 entries). please find the pseduo code- [Serializable] public class MyClass : ISerializable { internal static Dictionary<long, string> dict

JSON.parse or alternative library that will also parse dates

北战南征 提交于 2020-01-15 11:45:30
问题 I'm using Json.NET to serialize some data. It is very flexible with how dates are serialized so I can output it to any format necessary. Is there a date format that the browser provided JSON.parse function will deserialize into Date objects? If not, does anyone know of a good library that deserializes JSON into JavaScript objects, including dates? I really don't want to have to use a RegExp and a whole bunch of ugly code to parse dates after deserializing the rest of the JSON; I just want a

Mongodb saves list of object

守給你的承諾、 提交于 2020-01-15 11:36:29
问题 I know how to save a list of String Now, e.g. I create my own Animal class But when I try to save list in mongodb, it gives java.lang.IllegalArgumentException: can't serialize class Project I do create a new mongo collection Animal, but it is still not working. 回答1: You might check out Morphia or similar, where you can create object models and save them directly to Mongo. http://code.google.com/p/morphia/ 回答2: If Animal class extend ReflectionDBObject then you can insert list of Animals.

How can I serialize a class to XML using Windows Phone 8 SDK?

穿精又带淫゛_ 提交于 2020-01-15 10:55:29
问题 I've got one attribute (_XMLPlaylist) that I want to serialize in a XML-file likeshown in the code: private void btn_Save_Click(object sender, RoutedEventArgs e) { _Playlist.Pl_Name = tb_Name.Text.ToString(); _XMLPlaylist.Playlists.Add(_Playlist); IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication(); using (IsolatedStorageFileStream isoStream = new IsolatedStorageFileStream(StudiCast.Resources.AppResources.Playlists, FileMode.CreateNew, isoStore)) { using