serialization

Silverlight webservice call works in Studio but fails when run from website

笑着哭i 提交于 2019-12-31 01:13:07
问题 We are building a Silverlight application and have calls to a Silverlight-WCF service. When running the application from Visual Studio everything works perfectly. When we deploy to the website and run the application we get the following error (or one much like it) every time we call the web-service. Message: Unhandled Error in Silverlight Application An exception occurred during the operation, making the result invalid. Check InnerException for exception details. at System.ComponentModel

Ignore property of a property in Xml Serialization in .NET using XmlSerializer

感情迁移 提交于 2019-12-31 00:57:28
问题 I am carrying out Xml serrialization using XmlSerializer . I am carrying out serialization of ClassA , which contains property named MyProperty of type ClassB . I don't want a particular property of ClassB to be serialized. I have to use XmlAttributeOverrides as the classes are in another library. If the property was in ClassA itself, it would have been straightforward. XmlAttributeOverrides xmlOver = new XmlAttributeOverrides(); XmlAttributes xmlAttr = new XmlAttributes(); xmlAttr.XmlIgnore

Problem AJAX(ing) JSON object on Mac Firefox version (3.6.12)

落花浮王杯 提交于 2019-12-30 22:57:09
问题 Let's say I want to call some server method and pass it the following JSON object: var t = { "test": 0}; I'm using jQuery library $.ajax method with the following options: type: "POST", async: true, url: 'mypage.aspx?Action=myAction, data: { test: JSON.stringify(t, null, 2) }, contentType: 'application/x-www-form-urlencoded', dataType: 'json', . . . On the server side I fetch the data using following code: public string GetInputStream() { string inputContent; using (var sr = new System.IO

Add Serialize attribute to type from third-party lib

痞子三分冷 提交于 2019-12-30 22:51:47
问题 I'm trying to add serialization functionality to one of my structs in Rust. It's an event for a calendar and looks like this: #[derive(PartialEq, Clone, Encodable, Decodable)] pub struct Event { pub id: Uuid, pub name: String, pub desc: String, pub location: String, pub start: DateTime<Local>, pub end: DateTime<Local>, } The struct uses two different types from third-parties, the Uuid is from https://github.com/rust-lang/uuid and the DateTime from https://github.com/lifthrasiir/rust-chrono.

Avro schema doesn't honor backward compatibilty

橙三吉。 提交于 2019-12-30 17:36:09
问题 I have this avro schema { "namespace": "xx.xxxx.xxxxx.xxxxx", "type": "record", "name": "MyPayLoad", "fields": [ {"name": "filed1", "type": "string"}, {"name": "filed2", "type": "long"}, {"name": "filed3", "type": "boolean"}, { "name" : "metrics", "type": { "type" : "array", "items": { "name": "MyRecord", "type": "record", "fields" : [ {"name": "min", "type": "long"}, {"name": "max", "type": "long"}, {"name": "sum", "type": "long"}, {"name": "count", "type": "long"} ] } } } ] } Here is the

JSON.NET serialization trouble

荒凉一梦 提交于 2019-12-30 17:21:10
问题 I have a class with property type of Point ( struct in .NET Framework). I use JsonConvert from Newton.Json to serialize it to JSON. But result is "Point" : "100,100" Instead of "Point" : { X: "100", Y: "100"} When I replace JsonConvert with standard JavascriptSerializer, all works fine. But I want to use JsonConverter from JSON.Net, because it's much faster. 回答1: That's because Point has defined its own TypeConverter and JSON.NET uses it to do the serialization. I'm not sure whether there is

How to do Conditional Serialization using C# - NewtonSoft.Json

时光总嘲笑我的痴心妄想 提交于 2019-12-30 13:42:28
问题 I am doing json serialization using NewtonSoft.Json public class CommonBase { [JsonProperty(PropertyName = "u_customer_id")] public long CustomerId { get; set; } } I want to do a conditional serialization so that if CustomerId value is 0, I want to set a blank value for CustomerId during json serialization. Since CommonBase is a base class and I am not able to change data type from long to string . How can I achieve this? 回答1: You almost have the answer in your question title. What you are

Task not Serializable - Spark Java

不想你离开。 提交于 2019-12-30 13:24:19
问题 I'm getting the Task not serializable error in Spark. I've searched and tried to use a static function as suggested in some posts, but it still gives the same error. Code is as below: public class Rating implements Serializable { private SparkSession spark; private SparkConf sparkConf; private JavaSparkContext jsc; private static Function<String, Rating> mapFunc; public Rating() { mapFunc = new Function<String, Rating>() { public Rating call(String str) { return Rating.parseRating(str); } };

what's the point of serializing arrays to store them in the db?

萝らか妹 提交于 2019-12-30 13:18:46
问题 I see that people store arrays as like: a:6:{i:0;s:5:"11148";i:1;s:5:"11149";i:2;s:5:"11150";i:3;s:5:"11153";i:4;s:5:"11152";i:5;s:5:"11160";} why can't they just be: 11148,11149,11150,11153... and have sql "Type" be "Array" ? this way it's shorter and you can change the values directly in the databse without having to alter "s:" or "i:". 回答1: I've not seen this a whole lot. But it's clearly done for implementation ease. Serializing data allows to store quasi binary data. Your second example

Pickle Python Serialization

▼魔方 西西 提交于 2019-12-30 12:06:23
问题 In layman's terms, what is "Serialization", and why do I need it? I read the Wikipedia entry, but still don't understand it. Why do I need to convert data into a sequence of bits to store it in a file? I am specifically concerned with using Python's pickle module to do serialization. Thanks for the time! 回答1: You can save the state of a programm (of specific objects). Imagine you have a program which runs for many hours or even days. Using pickle you can save the state of the calculation,