deserialization

Serialization/deserialization ClassCastException: x cannot be cast to java.io.ObjectStreamClass

我只是一个虾纸丫 提交于 2020-01-04 13:24:17
问题 Using Java's native serialization, I'm intermittently seeing ClassCastExceptions java.lang.ClassCastException: myCompany.MyClass$MembershipServiceMethod cannot be cast to java.io.ObjectStreamClass or (less frequently) java.lang.ClassCastException: java.lang.String cannot be cast to java.io.ObjectStreamClass when I deserialize objects of a particular immutable class. That is to say, the exception is always thrown for particular serialized representations, but most objects can be successfully

Serialization/deserialization ClassCastException: x cannot be cast to java.io.ObjectStreamClass

坚强是说给别人听的谎言 提交于 2020-01-04 13:24:13
问题 Using Java's native serialization, I'm intermittently seeing ClassCastExceptions java.lang.ClassCastException: myCompany.MyClass$MembershipServiceMethod cannot be cast to java.io.ObjectStreamClass or (less frequently) java.lang.ClassCastException: java.lang.String cannot be cast to java.io.ObjectStreamClass when I deserialize objects of a particular immutable class. That is to say, the exception is always thrown for particular serialized representations, but most objects can be successfully

Serialization/deserialization ClassCastException: x cannot be cast to java.io.ObjectStreamClass

∥☆過路亽.° 提交于 2020-01-04 13:24:02
问题 Using Java's native serialization, I'm intermittently seeing ClassCastExceptions java.lang.ClassCastException: myCompany.MyClass$MembershipServiceMethod cannot be cast to java.io.ObjectStreamClass or (less frequently) java.lang.ClassCastException: java.lang.String cannot be cast to java.io.ObjectStreamClass when I deserialize objects of a particular immutable class. That is to say, the exception is always thrown for particular serialized representations, but most objects can be successfully

ClassNotFoundException during Deserialization of a just-serializaed class

这一生的挚爱 提交于 2020-01-04 09:06:28
问题 I was having an issue with deserializing an object. The current project has a plugin-style architecture, so I have jars that contain class files that are loaded at runtime. I was unable to deserialize an object that contained a class that was found in one of those jars, so I wrote a quick test method that gets called mid-stream that just loaded the plugins, instantiates the correct one (the object implements a particular interface so I can identify it via .isAssignableFrom(..) ), serializes

Type Information within serialized JSON using GSON

独自空忆成欢 提交于 2020-01-04 05:55:19
问题 Using Jackson we have the option to attach the type info to the serialized object (http://jackson.codehaus.org/1.5.5/javadoc/org/codehaus/jackson/annotate/JsonTypeInfo.html). Is there a way to do this using GSON like: { propertyName:"test", _className:"foo.bar.TestClass" } The idea is to have it generic, so when a ArrayList<Object> is deserialized, the right object instances are restored with it. I saw this question: https://stackoverflow.com/a/8683689/1001027 that is more or less what I need

How to deserialize object that can be an array or a dictionary with Newtonsoft?

假装没事ソ 提交于 2020-01-04 05:22:07
问题 I am using an API that returns a json object that I need to deserialize. My problem is that one of the members of those object is sometimes an empty array ("[]") and sometimes a dictionary ("{"1":{...}, "2":{...}}"). I want to deserialize it into either an array or a dictionary, since I don't car about the IDs, I just want a list of all the objects. Here is how I deserialize the object: var response = JsonConvert.DeserializeObject<Response>(json); And here is the definition of the Response

Nested JSONObject Deserialize to JSONObject

夙愿已清 提交于 2020-01-04 05:16:16
问题 So I'm working on deserializing a nested JSONObject, but don't want to create a class for each nested object. I was trying to take on of the nested JSONObjects and put it in a JSONObject. public class ContainerStatus { @JsonProperty("name") private String name; @JsonProperty("state") private JSONObject state; @JsonProperty("lastState") private JSONObject lastState; @JsonProperty("ready") private Boolean ready; @JsonProperty("restartCount") private Integer restartCount; @JsonProperty("image")

WCF Serialize Array or Collection Without a Container

别说谁变了你拦得住时间么 提交于 2020-01-04 05:08:18
问题 I have a situation where we are connecting to a SOAP service. The response we get back looks something like this: <SomeObject> <item1>1</item1> <thing1>2</thing1> <arrayItem><foo>text</foo></arrayItem> <arrayItem><foo>text1</foo></arrayItem> <arrayItem><foo>text2</foo></arrayItem> </SomeObject> I need to replicate the output of that response. The issue I keep running into is that the <arrayItem> 's are encapsulated by <arrayItemList> and I really need the <arrayItemList> to go away. Does

DataContractJsonSerializer generic list containing element type's subtypes

柔情痞子 提交于 2020-01-04 02:53:13
问题 I'm going to use DataContractJsonSerializer for JSON serialization/deserialization. I have two object types in the JSON array and want them both to be deserialized into corresponding object types. Having the following class defnitions [DataContract] public class Post { [DataMember(Name = "content")] public String Content { get; set; } } [DataContract] public class User { [DataMember(Name = "user_name")] public String UserName { get; set; } [DataMember(Name = "email")] public String Email {

Convert json to datatable vb

百般思念 提交于 2020-01-04 02:46:08
问题 Good morning, today i was trying to convert my json to datatable. This is what i'm trying to do Dim webclient_server7 As New System.Net.WebClient Dim json_result As String = webclient_server7.DownloadString("http://myhost/api/mycontroller/GetQuery") Dim json_jsonstring = Newtonsoft.Json.JsonConvert.SerializeObject(json_result) Try Dim table As DataTable = JsonConvert.DeserializeObject(Of DataTable)(json_jsonstring) Catch ex As Exception MsgBox("An exception occured: " & ex.Message) End Try