Class JsonToJava

java.lang.Object
edu.wisc.game.reflect.JsonToJava

public class JsonToJava
extends Object
Tools for importing Java objects from JSON structures. The conversion is guided by the structure of the destination Java objects. Not every Java object can be deserialized by this technique; for example, if a Java object has a field of the type Vector (or Vector<Object>), rather than (or Vector<SomeClass>), this tool will not know what kind of objects it is to be filled with.
  • Constructor Details

  • Method Details

    • json2java

      public static Object json2java​(jakarta.json.JsonObject jo, Object dest) throws ReflectiveOperationException
      Fills the fields of Java object dest from JSON structure jo.
      Parameters:
      jo - A JSON object (e.g. read from disk, or received via internet)
      dest - A Java object whose fields will be set, recursively, from the JSON objects. This will be done by invoking the appropriate setter methods of the relevant fields.
      Throws:
      ReflectiveOperationException