serialization

DataContractJsonSerializer with object type member

陌路散爱 提交于 2020-01-25 07:09:22
问题 I have the following serialization method: private string Serialize(Message message) { byte[] json; using (var ms = new MemoryStream()) { var ser = new DataContractJsonSerializer(typeof(Message)); ser.WriteObject(ms, message); json = ms.ToArray(); } return Encoding.UTF8.GetString(json, 0, json.Length); } I'm trying to serialize the following object: [DataContract] public class Message { [DataMember(Name = "technical", Order = 1)] public Technical Technical; [DataMember(Name = "payload", Order

In a WCF proxy-generated client, what determines the serializer used?

筅森魡賤 提交于 2020-01-25 05:20:29
问题 When I expose a WCF service using DataContact/DataMember attributes, each service reference I make in other projects to this service generates classes with DataContract/DataMember attributes (as well as IExtensibleDataObject interface implementation, etc.). In another project, I have to use a SOAP service whose WSDL has not been generated by WCF, but by some other tool I don't know and can't change the behavior. My problem is that the code generated by my svcutil proxy is a little bit less

Custom XML serialization with inheritance

[亡魂溺海] 提交于 2020-01-25 00:33:45
问题 I have the following class structure which I want to serialize: [XmlRoot("SomeClass")] public class SomeClass { private BaseClass[] _itemArray; public BaseClass[] ItemArray { get { return _itemArray; } set { _itemArray = value; } } public PPSPStatReportMessage() : base() { } } public class SomeOtherClass { private int _property5; [XmlAttribute("Property5")] public int Property5 { get { return _property5; } set { _property5 = value; } } private string _property6; [XmlText()] public string

jQuery Sortable updated data not being serialized

坚强是说给别人听的谎言 提交于 2020-01-24 19:05:27
问题 I am using the jQuery Sortable plugin. Looking at the basic example on how to serialize the data I have the below code. <div class='span4'> <ol class='serialization vertical'> <li data-id='1' data-name='Item 1' data-status='1'>Item 1 <span class="status">toggle</span></li> <li data-id='2' data-name='Item 2' data-status='1'>Item 2 <span class="status">toggle</span></li> <li data-id='3' data-name='Item 3' data-status='1'>Item 3 <span class="status">toggle</span></li> <li data-id='4' data-name=

Laravel Event exceeds Pusher allowed limit

只愿长相守 提交于 2020-01-24 17:57:26
问题 I have an event in my Laravel application that for specific records it exceeds the allowed maximum limit (10240 bytes) of Pusher. Is it correct that Laravel serializes every public attribute on the Event class? If so I suspect that the serialized model should not exceed the 10kb limit but it fails anyway. Are there any approaches to decrease the size of the data content? class PostChanged implements ShouldBroadcast { use Dispatchable, InteractsWithSockets, SerializesModels; public $post; /**

How to store object represented as Json string into Couchbase Lite?

血红的双手。 提交于 2020-01-24 17:53:27
问题 I use Couchbase Lite in my Android app. In the app, I retrieve a bunch of Json objects from a server which I want to store locally. But I can't seem to find a way to do that without prior having to serialize them into HashMap. Since the data is stored as Json anyway, that infers unnecessary overhead and results in a lot of boilerplate code. If I should be more specific, this is a kind of Json I fetch: "events":[ { "title":"event1", "venue":{ "name":"venue1" } ] I use Gson to convert what goes

Storing a string[][]-Array in a database

心已入冬 提交于 2020-01-24 16:25:59
问题 I would like to store a string[][]-array in a database as datatype "blob". I just found out that I have to convert it, otherwise the data would be practically lost. What would be the best way to do that? I suppose I should serialize and de-serialize the array, unfortunately I am not quite experienced in that area. So any help would be appreciated. PS: I guess I should have said that I need to do that on Android, thus using SQLite. The string[][] has no fixed number of rows or columns. 回答1:

Switching to Release Build causes runtime error in Web Reference

﹥>﹥吖頭↗ 提交于 2020-01-24 15:56:07
问题 I've got a problem with a SOAP Web Reference that was generated by Visual Studio 2005 (.NET framework is v2.0.50727.42) - it works fine under the Debug build configuration (and has for months) but now that I want to go live and have compiled using the Release configuration, it has stopped working. Exceptions are raised at runtime whenever I call a method on the Web Reference. The most common exception is: System.InvalidOperationException: There was an error generating the XML document. --->

ShouldSerialize method is not triggered in .NET Core 3

感情迁移 提交于 2020-01-24 15:09:25
问题 I normally use ShouldSerialize to exclude properties that have no data such as array but now, it does not appear to be triggered when I'm only using JSON serializer in .NET Core 3 . It was being triggered when using NewtonSoft but I've removed it from my project since it no longer appears to be required. For example: private ICollection<UserDto> _users; public ICollection<UserDto> Users { get => this._users ?? (this._users = new HashSet<UserDto>()); set => this._users = value; } public bool

IOException at java.io.File.createNewFile();

丶灬走出姿态 提交于 2020-01-24 14:25:28
问题 I do have some code for serialization which does not work. I have tried to insert both CanRead() and CanWrite() in if-statements which showed they did not have permissions to read and write. I have also tried to insert 'java.io.File.setReadable' and 'java.io.File.setWriteable to true but it still throws the error. The code is as following: public static void save(Object obj, String filename) throws FileNotFoundException, IOException { File f = new File("c:/DatoChecker/" + filename); File dir