serialization

How to serialize using System.Json in MonoTouch

夙愿已清 提交于 2020-01-21 18:02:11
问题 My other question seems to be too generic, so I tought I'd create a new one on the details. Sorry if that is considered bad practice. I am trying to serialize C# objects to JSON strings with MonoTouch and the System.Json namespace in a way that doesn't require me to descend through the object(s) myself. Is that possible? If yes, how to do it properly? De-serialization works well by implicitly casting a JsonValue to a string, int, whatever. Also, descending in the hierarchy is no problem. Like

.net binary formatter deserialize an object whose definition has changed a lot

余生颓废 提交于 2020-01-21 12:15:28
问题 I am trying to deserialize a file which is serialized using an older version. In the new version, We have done the following things change namespace Change class member access level, from private to public Add a new inter parent class. Class A was derived from Base. Now, Class A is derived from B, and B is derived from Base. In B, there is no new member introduced. Base class adds a new member. I know using SerializationBinder can solve issue 1. For the new added class member, I have marked

How to set the default namespace using JAXB

霸气de小男生 提交于 2020-01-21 11:35:08
问题 I have a ATOM-XML representation of my data that is returned via a Spring MVC web service. I'm using JAXB to do the serialization, I have a number of namespaces but I want the default namespace set to Atom with no prefix. Here is what I have so far in package-info.java but the atom prefix is being set to ns3. @XmlSchema(namespace = com.mycomponay.foo.ATOM_NAMESPACE, xmlns = { @XmlNs(prefix = "foo", namespaceURI = com.mycomponay.foo.NAMESPACE_FOO), }, elementFormDefault = javax.xml.bind

How to store Primitive Datatypes , Strings in a HBase Column and Retrieve Them Using Serialization and Deserialization?

醉酒当歌 提交于 2020-01-21 10:35:46
问题 How to store Primitive Datatypes , Strings in a HBase Column and Retrieve Them. Normally when we want to store data in HBase table we do as below. Configuration conf = HBaseConfiguration.create(); HTable table = new HTable(conf, "people"); Put put = new Put(Bytes.toBytes("doe-john-m-12345")); put.add(Bytes.toBytes("personal"), Bytes.toBytes("givenName"), Bytes.toBytes("John")); put.add(Bytes.toBytes("personal"), Bytes.toBytes("mi"), Bytes.toBytes("M")); put.add(Bytes.toBytes("personal"),

is there a difference between [Serializable] and [Serializable()] in c#?

馋奶兔 提交于 2020-01-21 07:09:05
问题 I've bumped into examples using either of both notations. I can't find anything about it what tells which one is the common one, why 2 notations are allowed, and if there is actually any subtle difference between the two. anyone an idea? 回答1: Nope, no functional difference. Why the 2 different styles, you ask? The first notation is allowed for brevity. The 2nd notation is allowed because some attributes take parameters: [Category("Foobar related methods.")] public void Foo() { } Also note

Java: Should serializable inner & anonymous classes have SerialVersionUID?

给你一囗甜甜゛ 提交于 2020-01-21 05:20:12
问题 Although I'm not currently planning to serialize anything, I give all serializable outer classes, as well as static nested classes a SerialVersionUID , because that is the proper way to do it. However, I've read here that Serialization of inner classes (i.e., nested classes that are not static member classes), including local and anonymous classes, is strongly discouraged for several reasons. ... So my question is: Should I give inner and anonymous classes a SerialVersionUID each, or should I

Java: Should serializable inner & anonymous classes have SerialVersionUID?

这一生的挚爱 提交于 2020-01-21 05:20:08
问题 Although I'm not currently planning to serialize anything, I give all serializable outer classes, as well as static nested classes a SerialVersionUID , because that is the proper way to do it. However, I've read here that Serialization of inner classes (i.e., nested classes that are not static member classes), including local and anonymous classes, is strongly discouraged for several reasons. ... So my question is: Should I give inner and anonymous classes a SerialVersionUID each, or should I

json.dumps(): escaping forward slashes

让人想犯罪 __ 提交于 2020-01-21 05:00:08
问题 Since forward slashes can only occur in strings inside a JSON serialized object and are not escaped (in the default settings), using json.dump(some_dict).replace('/', r'\/') reliably works, but it looks hacky. I know that forward slashes don't have to be escaped, but you may escape them, and for my usecase I'd like to have them escaped. Is there a way to to let the JSONEncoder escape forward slashes without manually escaping them? 回答1: Only escape forward slashes when encode_html_chars=True

Deserialize a property as an ExpandoObject using JSON.NET

被刻印的时光 ゝ 提交于 2020-01-21 04:06:32
问题 For example, there's an object like the next one: public class Container { public object Data { get; set; } } And it's used this way: Container container = new Container { Data = new Dictionary<string, object> { { "Text", "Hello world" } } }; If I deserialize a JSON string obtained from serializing the above instance, the Data property, even if I provide the ExpandoObjectConverter , it's not deserialized as an ExpandoObject : Container container = JsonConvert.Deserialize<Container>(jsonText,

Java- Save object data to a file [closed]

爱⌒轻易说出口 提交于 2020-01-21 03:40:48
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 6 years ago . I've seen so many different posts about what way you're supposed to serialize an object to a file, and all of them conflict in nature on how to do it and what the best practices are. So here's what I'm trying to save: public class IHandler{ public double currentLoad; public String currentPrice;