I'm looking to share object data between two independent desktop applications. Normally, I would use a Serialization Library to serialize objects in one app, and then Deserialize them in the other app (and casting the data to an object).
The Problem:
- I'm serializing objects in C#
- I want to deserialize them in Java
Example
Here is a c# class (Foo) that I want to deserialize in Java:
class Foo
{
public List<Bar> BarList {get;set;}
public string Name { get; set; }
}
class Bar
{
public string X { get; set; }
public int Y { get; set; }
}
Note: I'm using JSON.NET to serialize
JSON for an example Foo Object
{ "BarList": [ { "X": "hi", "Y": 5 }, { "X": "hello", "Y": 10 } ], "Name": "foo" }
Consuming this object in Java
Let's assume I have a very similar Foo class in Java. Instead of Properties, it has standard private members with public getter/setter methods.
Now, I could simply do something like:
class Foo
{
private ArrayList<Bar> barList;
private string name;
public Foo(string pathToJsonFile)
{
// Method/Code to manually grab the needed JSON and call setters
}
// Setters/Getters
}
This solution works, but I would rather avoid having this constructor on every single object in my Java project. Plus, if I have deeply coupled objects, this method would be huge (deserialize this object, but it contains objects that also need deserialized, etc, etc).
My Question:
Are there any Deserialization methods that are in the Java Standard Library, that could make this process easier?
Algorithm ideas would also be appreciated (I don't mind creating a small framework).
Third-party solutions are okay, as long as they are completely open-source, with no .jar dependencies.