Package edu.wisc.game.reflect
Class JsonReflect
- java.lang.Object
-
- edu.wisc.game.reflect.JsonReflect
-
public class JsonReflect extends Object
Tools for exporting Java objects as JSON structures
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description jakarta.json.JsonObjectBuilder
reflectToJSON(Object o)
Converts a Java object to a JSON object, to the extent possiblejakarta.json.JsonObjectBuilder
reflectToJSON(Object o, int level)
static jakarta.json.JsonArray
reflectToJSONArray(Object o, boolean skipNulls)
static jakarta.json.JsonObject
reflectToJSONObject(Object o, boolean skipNulls)
Converts a Java object to a JSON object, to the extent possible.static jakarta.json.JsonObject
reflectToJSONObject(Object o, boolean skipNulls, HashSet<String> excludableNames)
Converts a Java object to a JSON object, to the extent possible.static jakarta.json.JsonObject
reflectToJSONObject(Object o, boolean skipNulls, HashSet<String> excludableNames, int _maxLevel)
-
-
-
Method Detail
-
reflectToJSON
public jakarta.json.JsonObjectBuilder reflectToJSON(Object o)
Converts a Java object to a JSON object, to the extent possible
-
reflectToJSON
public jakarta.json.JsonObjectBuilder reflectToJSON(Object o, int level)
-
reflectToJSONObject
public static jakarta.json.JsonObject reflectToJSONObject(Object o, boolean skipNulls)
Converts a Java object to a JSON object, to the extent possible.- Parameters:
o
- Must not be an array
-
reflectToJSONObject
public static jakarta.json.JsonObject reflectToJSONObject(Object o, boolean skipNulls, HashSet<String> excludableNames)
Converts a Java object to a JSON object, to the extent possible.- Parameters:
o
- Object to convertskipNulls
- If true, the output won't contain the fields that have null values in oexcludableNames
- If not null, contains the set of field names that should be ignored. Additinally, it can contain something like "level.name", where the field "name" is excluded only if it occurs on level "level". This is handy for handling something like {"id": 0, "value": {"id":77, ...}}, when you only want to remove the top-level ID.
-
reflectToJSONObject
public static jakarta.json.JsonObject reflectToJSONObject(Object o, boolean skipNulls, HashSet<String> excludableNames, int _maxLevel)
-
reflectToJSONArray
public static jakarta.json.JsonArray reflectToJSONArray(Object o, boolean skipNulls)
-
-