[Solved] Does the Activity need to be Serializable when sending a class that implements Serializable through Intent and putExtra?

Does i.putExtra(String name, Serializable s) require the Activity where the Intent is sent from to implement Serializable? No, but it does mean that s cannot refer to the activity or other non-Serializable stuff or you will need to take steps to prevent the serialization from trying to serialize them (e.g., override the methods described in … Read more

[Solved] Serializing not-nested objects as nested

I’m going to take a crack at it here and assume that with the info you’ve given you need a class structure like this: class Book { [XmlAttribute(“bookAttribute”)] public string bookAttribute = “”; [XmlElement(“Shelf”)] List<Shelf> Shelves = new List<Shelf>(); } class Shelf { } Then when you create the programmatic relationship between a book and … Read more

[Solved] Flatbuffers usage [closed]

Flatbuffers are a compact binary representation of a given data structure, with the promise that it can be used “straight from the wire”, without any deserialization after the fact. By contrast, protocol buffers fill the same niche but need to be (de)serialized. For your purposes, just stick with JSON or YAML, since “readable by humans” … Read more

[Solved] If a class implements serializable interface then is its child class also serialize or not?

The Serializable interface does nothing by itself, it is merely, as you remarked, a marker interface to show Java that this particular class is serializable. That means that if you denote a class with this interface, all child classes will be treated as serializable by themselves (just like normal inheritance), but the task of a … Read more

[Solved] Add variable to json string in c#

Your question is not clear enough. But if I understand you correctly you want to convert this json { “fields”:{ “ID”: ID, “Device Name”: deviceName } } into string. I strongly suggest you use serialization libraries and do not write json yourself. You can easily create a class or dictionary and serialize it to that … Read more

[Solved] Go deserialization when type is not known

TL;DR Just use json.Unmarshal. You can wrap it lightly, using your transport, and call json.Unmarshal (or with a json.Decoder instance, use d.Decode) on your prebuilt JSON bytes and the v interface{} argument from your caller. Somewhat longer, with an example Consider how json.Unmarshal does its own magic. Its first argument is the JSON (data []byte), … Read more

[Solved] Serialise List

You can do this easily using JSON.net. Here’s an example: List<Dictionary<String, Object>> Details = new List<Dictionary<string, object>> { new Dictionary<string,object> { {“abc” , “def”}, {“123”, 234} }, new Dictionary<string,object> { {“abc1” , “def1”}, {“1231”, 2341} } }; // serializing to: [{“abc”:”def”,”123″:234},{“abc1″:”def1″,”1231”:2341}] string json = JsonConvert.SerializeObject(Details); // de-serializing to a new List<Dictionary<String, Object>>. List<Dictionary<String, Object>> newDic … Read more

[Solved] Json data not converting to List

Firstly, both your input and output JSON are syntactically invalid: they are missing outer braces { and }. For the remainder of this answer, I’m going to assume this is a typo in the question. Assuming you have not done so already, you could install json.net as shown here and then use LINQ to JSON … Read more

[Solved] Deserialize nested JSON into C# class

Your data model should be as follows: public class Info { public string prop1 {get;set;} public string prop2 {get;set;} public int prop3 {get;set;} // Modified from //public Dictionary<string, List<int>> prop4 {get;set} public List<Dictionary<string, int>> prop4 {get;set;} } public class Response { // Modified from //public class Dictionary<string, List<Info>> Item {get;set;} public Dictionary<string, Info> Items {get;set;} … Read more

[Solved] Serialize List using Json.net

Serializing a List<LinkedListNode<string>> is a bit of an odd thing to do – normally one would just serialize the underlying linked list. Perhaps you’re trying to serialize a table that gives the nodes in a different order than the underlying list? If that’s the case, it might appear that one could serialize the node list … Read more

[Solved] How do I properly test the char[ ] fields in my custom object for nulls, blanks, or empty? and Why do char[ ] indicate a length of 11?

String.valueOf().length() returns 11 because that is the number of digits/characters in the output (i.e. [@936016386 – an address – has 11 characters) solved How do I properly test the char[ ] fields in my custom object for nulls, blanks, or empty? and Why do char[ ] indicate a length of 11?