deserialization

Serializing C++ objects

纵然是瞬间 提交于 2019-12-22 09:13:31
问题 I would like to implement a Serialization Class which takes in an object and converts it into a binary stream and stored in a file. Later, the object should be reconstructed from a file. Though this functionality is provided by BinaryFormatter in C#, I would like to design my own Serialization class from scratch. Can someone point to some resources ? Thanks in advance 回答1: I have been using boost::serialization library for a while now and I think it is very good. You just need to create the

Can not find a deserializer for non-concrete Map type [map type; class javax.ws.rs.core.MultivaluedMap

这一生的挚爱 提交于 2019-12-22 08:59:44
问题 I'm having the following issue in Deserialization with org.codehaus.jackson.map.ObjectMapper that does not work for the following class. I'm not sure what is going wrong with the MultivaluedMap I'm using. public class ClassD { private ClassA objA; private ClassB objB; private final ClassC objC; private MultivaluedMap<String, String> headerMap; } public static void main(String[] args) { String fileName = "someFilePath"; mockCollection = fromJSON(new TypeReference<Collection<ClassD>>() {}, new

Serialize/Deserialize custom Map<Key, Object> in Jackson

夙愿已清 提交于 2019-12-22 08:05:28
问题 I have a pretty simple Map I want to serialize and deserialize in Jackson, but I can't get it to work. I have tried the following: @JsonSerialize(keyUsing=TurnKeySerializer.class) @JsonDeserialize(keyUsing = TurnKeyDeserializer.class) Map<TurnKey, PlayerTurn> publicTurns = new TreeMap<>(); @JsonIgnoreProperties(ignoreUnknown = true) @Data //Creates Getter/Setter etc public class TurnKey implements Comparable<TurnKey> { private final int turnNumber; private final String username; public

Deserialized Object Has All Values Set to Null

﹥>﹥吖頭↗ 提交于 2019-12-22 08:03:29
问题 I'm trying to deserialize JSON into a custom object but all my properties are set to null and not sure what's going on. Does anyone see anything wrong? JSON Example { "Keys": [ { "RegistrationKey": "asdfasdfa", "ValidationStatus": "Valid", "ValidationDescription": null, "Properties": [ { "Key": "Guid", "Value": "i0asd23165323sdfs68661358" } ] } ] } Here is my Code, where strResponseValid is the JSON above. Keys myDeserializedObjValid = (Keys)JsonConvert.DeserializeObject(strResponseValid,

ISO8601 to DateTime with time zone information preserved

╄→尐↘猪︶ㄣ 提交于 2019-12-22 06:17:10
问题 Below is a deserialization of an ISO8601 date string that contains time zone information. Notice that the time zone information is lost: scala> val date1 = new DateTime().withZone(DateTimeZone.forID("Europe/Berlin")) date1: org.joda.time.DateTime = 2013-09-22T18:42:15.348+02:00 scala> date1.getZone() res45: org.joda.time.DateTimeZone = Europe/Berlin scala> val date2 = new DateTime(date1.toString()) date2: org.joda.time.DateTime = 2013-09-22T19:42:15.348+03:00 scala> date2.getZone() res46: org

ISO8601 to DateTime with time zone information preserved

拟墨画扇 提交于 2019-12-22 06:17:06
问题 Below is a deserialization of an ISO8601 date string that contains time zone information. Notice that the time zone information is lost: scala> val date1 = new DateTime().withZone(DateTimeZone.forID("Europe/Berlin")) date1: org.joda.time.DateTime = 2013-09-22T18:42:15.348+02:00 scala> date1.getZone() res45: org.joda.time.DateTimeZone = Europe/Berlin scala> val date2 = new DateTime(date1.toString()) date2: org.joda.time.DateTime = 2013-09-22T19:42:15.348+03:00 scala> date2.getZone() res46: org

Why is this JSON returning as “Invalid JSON primitive”?

微笑、不失礼 提交于 2019-12-22 04:35:18
问题 The following JSON is not deserializing. It's obviously because the DECIMALS in the saves JSON. How do I fix this? This initial JSON comes from the server and IS VALID: { "AppropriationAmount": 25000000, "AppropriationHours": 56300, "ArrThreshold": 11, "ClientKey": 24, "Description": 'Find and incarcerate the escaped prisoner', "DirectHours": 50000, "EndDate": '3/31/2011', "EngineeringHours": 4000, "IndirectHours": 2000, "Key": 1589, "Number": '0', "OtherHours": 300, "ProductivityCurveType":

Deserialize ActiveRecord from JSON

…衆ロ難τιáo~ 提交于 2019-12-22 00:03:15
问题 I would like to save query result into redis using JSON serialization and query it back. Getting query results to json is pretty easy: JSON.generate(Model.all.collect {|item| item.attributes}) However I did not find a proper way to deserialize it back to ActiveRecord. The most straight-forward way: JSON.parse(@json_string).collect {|item| Model.new.from_json(item)} Gives me an error: WARNING: Can't mass-assign protected attributes: id So id gets empty. I thought of just using OpenStruct for

Serialize & Deserialize bean to json with Groovy

自闭症网瘾萝莉.ら 提交于 2019-12-21 17:30:54
问题 I've read this news about json with groovy http://www.infoq.com/news/2014/04/groovy-2.3-json. So I tried to native methods to (de)serialization of groovy bean containing dates. But I have issues whent using JsonOutput.toJson(object) with JsonObject.fromObject() with java.util.Date String jsonDat a= groovy.json.JsonOutput.toJson(contact) Contact reloadContact = new Contact(net.sf.json.JSONObject.fromObject(jsonData)) What is the right way to to this with native methods in groovy 2.3+ ?

JSON Serialize / Deserialize generic type with google-gson

泄露秘密 提交于 2019-12-21 17:23:42
问题 Well, I have to confess I'm not good at generic type in Java I've written a JSON serialize/deserialize class in C# using JavaScriptSerializer private static JavaScriptSerializer js = new JavaScriptSerializer(); public static T LoadFromJSONString<T>(string strRequest) { return js.Deserialize<T>(strRequest); } public static string DumpToJSONString<T>(T rq) { return js.Serialize(rq); } It works well in C#. Now I'm trying to convert, or atleast, write another JSON serialize/deserialize class in