public class JsonUtils extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
JsonUtils.OptionalFieldsDeserializationProblemHandler
A handler for optional fields.
|
| Constructor and Description |
|---|
JsonUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
defineOptionals(com.fasterxml.jackson.databind.ObjectMapper mapper,
Class<?> cls,
String... fieldNames)
Defines the given
fieldNames as optional during deserialization. |
static String |
escape(String input)
Escapes an input string for JSON.
|
static <R> R |
fromJson(Object json,
Class<R> cls)
Reads an Object from a JSON string.
|
static de.iip_ecosphere.platform.support.ServerAddress |
serverAddressFromJson(Object json)
Reads a
ServerAddress from a JSON string. |
static String |
toJson(Object obj)
Turns a
ServerAddress into JSON. |
static String |
toJson(de.iip_ecosphere.platform.support.ServerAddress address)
Turns a
ServerAddress into JSON. |
static String |
unescape(String input)
Unescapes an input string from JSON.
|
public static de.iip_ecosphere.platform.support.ServerAddress serverAddressFromJson(Object json)
ServerAddress from a JSON string.json - the JSON value, usually a StringtoJson(ServerAddress)public static String toJson(de.iip_ecosphere.platform.support.ServerAddress address)
ServerAddress into JSON.address - the address (may be null)serverAddressFromJson(Object)public static String toJson(Object obj)
ServerAddress into JSON.obj - the object (may be null), must have getters/setters for all attributes and a no-arg constructor
no-arg constructorfromJson(Object, Class)public static <R> R fromJson(Object json, Class<R> cls)
R - the object type, must have getters/setters for all attributes and a no-arg constructorjson - the JSON value (usually a String)cls - the class of the type to readtoJson(Object)public static String escape(String input)
input - the input stringpublic static String unescape(String input)
input - the input stringpublic static void defineOptionals(com.fasterxml.jackson.databind.ObjectMapper mapper,
Class<?> cls,
String... fieldNames)
fieldNames as optional during deserialization.mapper - the mapper to define the optionals oncls - the cls the class fieldNames are member offieldNames - the field names (names of Java fields)Copyright © 2022. All rights reserved.