serialization

Deserialize json array stream one item at a time

我们两清 提交于 2020-01-08 12:28:01
问题 I serialize an array of large objects to a json http response stream. Now I want to deserialize these objects from the stream one at a time. Are there any c# libraries that will let me do this? I've looked at json.net but it seems I'd have to deserialize the complete array of objects at once. [{large json object},{large json object}.....] Clarification: I want to read one json object from the stream at a time and deserialize it. 回答1: In order to read the JSON incrementally, you'll need to use

Deserialize json array stream one item at a time

谁说胖子不能爱 提交于 2020-01-08 12:27:53
问题 I serialize an array of large objects to a json http response stream. Now I want to deserialize these objects from the stream one at a time. Are there any c# libraries that will let me do this? I've looked at json.net but it seems I'd have to deserialize the complete array of objects at once. [{large json object},{large json object}.....] Clarification: I want to read one json object from the stream at a time and deserialize it. 回答1: In order to read the JSON incrementally, you'll need to use

Java serialization and deserialization when the state of the class changes

半世苍凉 提交于 2020-01-07 08:49:12
问题 How does serialization and deserialization work in the following cases: When a new field is added to the class. When a non static member is converted to static When a non transient field becomes transient When a transient field becomes non transient 回答1: In all of the cases described above, the java.io.InvalidClassException would be thrown in case you try to deserialize the class. The reason of this behaviour is that a serial version of the class used for deserialization does not match a

How to trim in JSON the miliseconds in DateTime serialization

痴心易碎 提交于 2020-01-07 07:43:35
问题 I have a WEB API 2 call, with Entity Framework. If I update a DateTime column from my entity that I read from the database with DateTime.Now , and I serialize it to the client, the column with DateTime that I received from the database has 3 numbers for the milliseconds, but the column with DateTime that I updated in the C# code has 6 digits. Below is the C# code in my controller: [Route("{id:long}/updatedatetime", Name = "UpdateDateTimeByID")] [HttpPost] [ResponseType(typeof(ClGroup))]

What's the best way to save movie objects inside other files and associate them with the ones in the actual collection?

筅森魡賤 提交于 2020-01-07 05:43:05
问题 I have a collection of Movie objects in a HashSet<Movie> . Movie type has properties such has Name , Year , Length , Genre , etc. I also has user profiles stored in individual files. I want to have each user to have a number of favorite movies. But I am not sure how to "connect"/reference these movies inside the user profiles. Should I just rely on names? What's the best way to store the favorite movies in these individual user profiles? I can't think of any other than using names, but this

GSON does not deserialize reference to outer class

浪尽此生 提交于 2020-01-07 05:29:05
问题 On my Java application, I defined two classes, called A and B where B is inner class of A . Both are defined as serializable public class A implements Serializable { int attrParent; List<B> items = new ArrayList<B>(); public void setAttrParent(int attrParent) { this.attrParent = attrParent; } public int getAttrParent() { return attrParent; } public class B implements Serializable { private int attr; public void setAttr(int attr) { this.attr = attr; } public int getAttr() { return attr; }

Serialize ids when saving emberjs model

放肆的年华 提交于 2020-01-07 05:28:06
问题 I have an emberjs application backed by a nodejs server and mongodb . Currently my database is sending documents with an '_id' field. I have the followign code to force Ember to treat '_id' as the primary key : App.ApplicationSerializer = DS.RESTSerializer.extend({ primaryKey: '_id' }); On the other hand i have two models related by a 'hasMany' relationship as such: App.Player = DS.Model.extend({ name: DS.attr('string'), thumbLink: DS.attr('string'), activeGame: DS.belongsTo('game', { async:

deserialize system.outofmemoryexception on a networkstream

时光毁灭记忆、已成空白 提交于 2020-01-07 05:09:14
问题 I've got a serializeable class called Cereal with several public fields shown here <Serializable> Public Class Cereal Public id As Integer Public cardType As Type Public attacker As String Public defender As String Public placedOn As String Public attack As Boolean Public placed As Boolean Public played As Boolean Public text As String Public Sub New() End Sub End Class My client computer is sending a new Cereal to the host by serializing it shown here 'sends data to host stream (c1) Private

Save and load a jagged array

余生颓废 提交于 2020-01-07 05:05:30
问题 How can I save a jagged array in C#? For example: I have the following jagged array: double[][,] myJaggedArr=new double[2][,]; myJaggedArr[0]=new double[3,3]{{1,2,3},{4,5,6},{7,8,9}}; myJaggedArr[1]=new double[3,3]{{1,1,1},{2,2,2},{3,3,3}}; How can I save this jagged array and how can I load it? what if I have a two jagged array and I want to save it in one file? I think it is better to make a class having these two jagged arrays so I can save an object of the class. I know that I can save

Is it possible to store styled text persistently?

为君一笑 提交于 2020-01-07 04:23:10
问题 So I was trying to serialize some DefaultStyledDocument objects using XMLEncoder. They encode just fine, however when I look at the data, it doesn't encode any actually data, it just gives the class file. I've looked on the internet and saw that many people had trouble with this, but there were no helpful solutions. The best answer I saw was "DefaultStyledDocument isn't a proper bean, so it won't work." So, is there anyway I can serialize DefaultStyledDocuments, without having to deal with