serialization

How to handle special characters like  when Serialize/Deserialize xml object?

我是研究僧i 提交于 2020-01-01 16:27:11
问题 I have some biz objects to store the customer names, sometimes the name contains some special characters like &#2; , &#3; . These names are imported from 3rd party, and I cannot delete the funny chars from the source. The application will serialize/deserialize the customer object by XmlSerializer, but the strange thing here is when I serialize the name with special chars, there are no errors, and the result will be like this <Name>Jim &#2;<Name> . But when I deserialize the output xml, I will

JavaScriptSerializer and monodevelop

你离开我真会死。 提交于 2020-01-01 14:58:13
问题 Im reading this book but I JavaScriptSerializer from the System.Web.Script.Serialization namespace because it seems to be unavailable? 回答1: Download source here and add as existing project. Then add as reference: http://www.bloxify.com/post/MonoTouch-Easy-JSON-Library.aspx Edit: You may also find that the monotouch linker is pretty aggressive. I would have code work fine in the simulator but crash in the device with method missing exceptions. Add a method somewhere in your app (you dont have

JSON: Serialize Guava Optional

ぃ、小莉子 提交于 2020-01-01 12:31:09
问题 Is there a Json Serializer/Deserializer for com.google.common.base.Optional? Out of the box this doesn't seem to work with Jackson, see below: package com.example; import java.io.IOException; import org.codehaus.jackson.JsonGenerationException; import org.codehaus.jackson.map.JsonMappingException; import org.codehaus.jackson.map.ObjectMapper; import com.google.common.base.Optional; public class TestClass { public Optional<String> myString; public TestClass() { myString = Optional.of(

c# xml serialization doesn't write null

血红的双手。 提交于 2020-01-01 12:09:19
问题 when I serialize a c# object with a nullable DateTime in it, is there a way to leave the null value out of the xml file instead of having <EndDate d2p1:nil="true" xmlns:d2p1="http://www.w3.org/2001/XMLSchema-instance" /> 回答1: You can use the Specified extended property to leave out null values (or any other value, for that matter). Basically, create another property with the same name as the serialized property with the word Specified added to the end as a boolean. If the Specified property

c# xml serialization doesn't write null

笑着哭i 提交于 2020-01-01 12:09:03
问题 when I serialize a c# object with a nullable DateTime in it, is there a way to leave the null value out of the xml file instead of having <EndDate d2p1:nil="true" xmlns:d2p1="http://www.w3.org/2001/XMLSchema-instance" /> 回答1: You can use the Specified extended property to leave out null values (or any other value, for that matter). Basically, create another property with the same name as the serialized property with the word Specified added to the end as a boolean. If the Specified property

Lazy, stream driven object serialization with protobuf-net

折月煮酒 提交于 2020-01-01 11:36:45
问题 We are developing a WCF service for streaming a large amount of data, therefore we have chosen to use WCF Streaming functionality combined with a protobuf-net serialization. Context: Generally an idea is to serialize objects in the service, write them into a stream and send. On the other end the caller will receive a Stream object and it can read all data. So currently the service method code looks somewhat like this: public Result TestMethod(Parameter parameter) { // Create response var

Lazy, stream driven object serialization with protobuf-net

本秂侑毒 提交于 2020-01-01 11:36:04
问题 We are developing a WCF service for streaming a large amount of data, therefore we have chosen to use WCF Streaming functionality combined with a protobuf-net serialization. Context: Generally an idea is to serialize objects in the service, write them into a stream and send. On the other end the caller will receive a Stream object and it can read all data. So currently the service method code looks somewhat like this: public Result TestMethod(Parameter parameter) { // Create response var

How can I control the order of attributes in my xml serialization?

元气小坏坏 提交于 2020-01-01 11:26:24
问题 Is there a way to have the System.Xml.Serialization serialize attributes in a specific order? I am creating new xml export and the attributes are not in the same order currently. I know that attribute order should not matter, but I have to send this xml to servers that may not have such enlightened ideas. 来源: https://stackoverflow.com/questions/14225529/how-can-i-control-the-order-of-attributes-in-my-xml-serialization

Python defaultdict(list) de/serialization performance

梦想的初衷 提交于 2020-01-01 10:45:08
问题 I am working on a script which needs to process a rather large (620 000 words) lexicon on startup. The input lexicon is processed word-by-word into a defaultdict(list) , with keys being letter bi and trigrams and values being lists of words that contain the key letter n-gram using for word in lexicon_file: word = word.lower() for letter n-gram in word: lexicon[n-gram].append(word) such as > lexicon["ab"] ["abracadabra", "abbey", "abnormal"] The resulting structure contains 25 000 keys, each

Python defaultdict(list) de/serialization performance

偶尔善良 提交于 2020-01-01 10:44:52
问题 I am working on a script which needs to process a rather large (620 000 words) lexicon on startup. The input lexicon is processed word-by-word into a defaultdict(list) , with keys being letter bi and trigrams and values being lists of words that contain the key letter n-gram using for word in lexicon_file: word = word.lower() for letter n-gram in word: lexicon[n-gram].append(word) such as > lexicon["ab"] ["abracadabra", "abbey", "abnormal"] The resulting structure contains 25 000 keys, each