serialization

Convert serialized C# DateTime to JS Date object

北城以北 提交于 2019-12-22 03:57:05
问题 How can I convert that date format /Date(1302589032000+0400)/ to JS Date object? 回答1: Remove the text first: var src = "/Date(1302589032000+0400)/"; //Remove all non-numeric (except the plus) src = src.replace(/[^0-9 +]/g, ''); //Create date var myDate = new Date(parseInt(src)); Here's a workding jsFiddle 来源: https://stackoverflow.com/questions/6928281/convert-serialized-c-sharp-datetime-to-js-date-object

Convert serialized C# DateTime to JS Date object

主宰稳场 提交于 2019-12-22 03:56:07
问题 How can I convert that date format /Date(1302589032000+0400)/ to JS Date object? 回答1: Remove the text first: var src = "/Date(1302589032000+0400)/"; //Remove all non-numeric (except the plus) src = src.replace(/[^0-9 +]/g, ''); //Create date var myDate = new Date(parseInt(src)); Here's a workding jsFiddle 来源: https://stackoverflow.com/questions/6928281/convert-serialized-c-sharp-datetime-to-js-date-object

DeflateStream doesnt work on MemoryStream?

拜拜、爱过 提交于 2019-12-22 03:51:03
问题 I have the following piece of code: MemoryStream resultStream = new MemoryStream(); string users = ""//Really long string goes here BinaryFormatter bFormatter = new BinaryFormatter(); using (MemoryStream assignedUsersStream = new MemoryStream()) { bFormatter.Serialize(assignedUsersStream, users); assignedUsersStream.Position = 0; using (var compressionStream = new DeflateStream(resultStream, CompressionLevel.Optimal)) { assignedUsersStream.CopyTo(compressionStream); Console.WriteLine(

Django Rest Framework: Serialize data from nested json fields to plain object

╄→гoц情女王★ 提交于 2019-12-22 03:40:30
问题 I want to serialize non-flat structure to a one flat object. Here's an example of an API call I receive (I cannot control it unfortunately): { "webhookEvent": "jira:issue_updated", "user": { "id": 2434, "name": "Ben", }, "issue": { "id": "33062", "key": "jira-project-key-111", "fields": { "summary": "The week ahead", }, "changelog": { "id": "219580", "items": [{ "field": "status", "fieldtype": "jira", "from": "10127", "fromString": "Submitted", "to": "10128", "toString": "Staged" }] },

C++ std::mt19937 and rng state save/load & portability

China☆狼群 提交于 2019-12-22 03:22:20
问题 I want to be able to save and load the state of an RNG so I can reproduce the same random values from a given point (application save/snapshot). I see there is an operator << and >> overload, which seems to save to a string as a sequence of numbers. Is that the best/only way to save? I wouldn't mind just having the fixed-size binary state value not this space separated string thing that I then need to prefix or put delimiters around for my file format. Is this at all portable? e.g. can I

Serialization Performance and Google Android

回眸只為那壹抹淺笑 提交于 2019-12-22 03:22:05
问题 I'm looking for advice to speed up serialization performance, specifically when using the Google Android. For a project I am working on, I am trying to relay a couple hundred objects from a server to the Android app, and am going through various stages to get the performance I need. First I tried a terrible XML parser that I hacked together using Scanner specifically for this project, and that caused unbelievably slow performance when loading the objects (~5 minutes for a 300KB file). I then

TypeLoadException when using PCL in .NET application if called class contains [OnDeserialized] method

此生再无相见时 提交于 2019-12-22 03:21:13
问题 I am adapting an existing .NET class library to a Portable Class Library. I am using profile 78 (.NET 4.5, Windows Store 8, Windows Phone 8) in favor of profile 158 (which also targets Silverlight 5) because I want to be able to compile the unsafe code of the original library. The .NET library contains quite a lot of classes marked [Serializable] , so I have implemented a support PCL library containing a dummy SerializableAttribute implementation: public class SerializableAttribute :

Newtonsoft JsonConvert.SerializeObject ignoring JsonProperty if name is uppercase

时光毁灭记忆、已成空白 提交于 2019-12-22 01:29:59
问题 I want to be able to use the CamelCasePropertyNameContractResolver but override it for specific property names. For this, I use the JsonProperty attribute. This works fine except when the name that I choose is fully uppercase. Any ideas what's wrong or how to get around it? In the example below, Bar is serialized to "BAR" when I don't use the CamelCasePropertyNameContractResolver, but is serialized to "bar" when I do use the resolver. Foo and CamelCaseProperty are serialized correctly in both

XmlSerializer.Deserialize on a List<> item

时间秒杀一切 提交于 2019-12-22 01:27:52
问题 I've tried all the solutions I could find on SO and elsewhere, but can't seem to figure out why this is not working. Straightforward deserialization of an XML string into an object, the object has one property - a List: [XmlTypeAttribute(AnonymousType = true)] public class UpdateData { [XmlArrayItem(ElementName = "Updates")] public List<Update> Updates { get; set; } public UpdateData() { Updates = new List<Update>(); } } public class Update { [XmlElement(ElementName = "MemberID")] public int

Serializing a vector

给你一囗甜甜゛ 提交于 2019-12-22 01:18:10
问题 I'm trying to implement loading and saving for a game I'm working on. What I want to save is: A char[][] (bidimensional array/matrix) An ArrayList<Entity> Entity is a super class for Dragon , Hero and Item . All three of these types can be contained at once in the ArrayList . So far I have this: package logic; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io