serialization

How to serialize a derived class in Silverlight

不打扰是莪最后的温柔 提交于 2020-02-04 07:23:18
问题 I created a custom control in XAML, and added some custom properties as well. Now, I want to serialize it to JSON if possible. Here is (essentially) what I have: public partial class MyCustomClass : UserControl { public Dictionary<char, int[]> ValueMap; public int Value { get; set; } } And in the code that handles serialization: public static string Serialize(object objectToSerialize) { using (MemoryStream ms = new MemoryStream()) { DataContractJsonSerializer serializer = new

NullPointerException when trying to write object instance to ObjectOutputStream

爷,独闯天下 提交于 2020-02-04 05:04:20
问题 I'm getting Exception in thread "main" java.lang.NullPointerException at java.io.FileOutputStream.<init>(FileOutputStream.java:201) at java.io.FileOutputStream.<init>(FileOutputStream.java:99) at lib.Entry.serialize(Entry.java:17) at main.Main.main(Main.java:8) Where Entry.java:17 is stream.writeObject(this); (see below) Entry.java package lib; import java.io.*; public class Entry { // Superclass. String filename; // Set below. String name; // Set by the subclass. public void main() { this

NullPointerException when trying to write object instance to ObjectOutputStream

柔情痞子 提交于 2020-02-04 05:04:05
问题 I'm getting Exception in thread "main" java.lang.NullPointerException at java.io.FileOutputStream.<init>(FileOutputStream.java:201) at java.io.FileOutputStream.<init>(FileOutputStream.java:99) at lib.Entry.serialize(Entry.java:17) at main.Main.main(Main.java:8) Where Entry.java:17 is stream.writeObject(this); (see below) Entry.java package lib; import java.io.*; public class Entry { // Superclass. String filename; // Set below. String name; // Set by the subclass. public void main() { this

Partial bean serialization and deserialization+merging

点点圈 提交于 2020-02-04 01:08:27
问题 I am developing a RESTful web service. I have a bunch of entity classes (mostly JPA entities, but also other beans). There are gazillions of object mapping, serialization, binding and whatnot libraries out there. I'm looking for a one that will enable me to: Serialize the entities to XML and JSON Serialization MUST support using getters , not only object fields. It MUST support views . By views I mean a way to specify a subset of the properties of the entity, which are to be serialized. For

Partial bean serialization and deserialization+merging

淺唱寂寞╮ 提交于 2020-02-04 01:08:05
问题 I am developing a RESTful web service. I have a bunch of entity classes (mostly JPA entities, but also other beans). There are gazillions of object mapping, serialization, binding and whatnot libraries out there. I'm looking for a one that will enable me to: Serialize the entities to XML and JSON Serialization MUST support using getters , not only object fields. It MUST support views . By views I mean a way to specify a subset of the properties of the entity, which are to be serialized. For

Symfony Serializer issue - NotNormalizableValueException

元气小坏坏 提交于 2020-02-03 11:38:28
问题 I have an issue when I'm using the serializer with FOSRestBundle in Symfony 4.1 I have the following error message : Could not normalize object of type App\Entity\Youp, no supporting normalizer found. Symfony\Component\Serializer\Exception\NotNormalizableValueException I don't understand why I have this issue, Symfony's Serializer should have an serializer object or I miss something ? See bellow my controller and my entity : <?php namespace App\Entity; use Doctrine\ORM\Mapping as ORM; /** *

Symfony Serializer issue - NotNormalizableValueException

半城伤御伤魂 提交于 2020-02-03 11:38:21
问题 I have an issue when I'm using the serializer with FOSRestBundle in Symfony 4.1 I have the following error message : Could not normalize object of type App\Entity\Youp, no supporting normalizer found. Symfony\Component\Serializer\Exception\NotNormalizableValueException I don't understand why I have this issue, Symfony's Serializer should have an serializer object or I miss something ? See bellow my controller and my entity : <?php namespace App\Entity; use Doctrine\ORM\Mapping as ORM; /** *

Why does specifying Map's initial capacity cause subsequent serializations to give different results?

帅比萌擦擦* 提交于 2020-02-03 10:08:11
问题 I am trying to compare 2 byte[] which are the results of serialization of the same object: 1 byte[] is created by serializing the object the other by deserializing the 1st byte[] and then serializing it again. I do not understand how these 2 arrays can be different. Deserializing the first byte[] should reconstruct the original object, and serializing that object is the same as serializing the original one. So, the 2 byte[] should be the same. However, under certain circumstances they can be

How to convert a dynamic object to JSON string c#?

本小妞迷上赌 提交于 2020-02-03 04:39:26
问题 I have the following dynamic object that I'm getting from a third party library: IOrderStore os = ss.GetService<IOrderStore>(); IOrderInfo search = os.Orders.Where(t => t.Number == "test").FirstOrDefault(); IOrder orderFound = os.OpenOrder(search, true); dynamic order = (dynamic)orderFound; dynamic requirements = order.Title.Commitments[0].Requirements; I need to parse it to a JSON string. I tried this (using JSON.net): string jsonString = JsonConvert.SerializeObject(requirements); return

Unable to deserialize ActorRef to send result to different Actor

自作多情 提交于 2020-02-02 04:30:10
问题 I am starting to use Spark Streaming to process a real time data feed I am getting. My scenario is I have a Akka actor receiver using "with ActorHelper", then I have my Spark job doing some mappings and transformation and then I want to send the result to another actor. My issue is the last part. When trying to send to another actor Spark is raising an exception: 15/02/20 16:43:16 WARN TaskSetManager: Lost task 0.0 in stage 2.0 (TID 2, localhost): java.lang.IllegalStateException: Trying to