Package org.pac4j.oauth.profile
Class JsonHelper
- java.lang.Object
-
- org.pac4j.oauth.profile.JsonHelper
-
public final class JsonHelper extends Object
This class is an helper to work with JSON.- Since:
- 1.0.0
- Author:
- Jerome Leleu
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ObjectgetElement(com.fasterxml.jackson.databind.JsonNode json, String name)Return the field with name in JSON as a string, a boolean, a number or a node.static com.fasterxml.jackson.databind.JsonNodegetFirstNode(String text)Return the first node of a JSON response.static com.fasterxml.jackson.databind.JsonNodegetFirstNode(String text, String path)Return the first node of a JSON response.static com.fasterxml.jackson.databind.ObjectMappergetMapper()static StringtoJSONString(Object obj)Returns the JSON string for the object.
-
-
-
Method Detail
-
getFirstNode
public static com.fasterxml.jackson.databind.JsonNode getFirstNode(String text)
Return the first node of a JSON response.- Parameters:
text- JSON text- Returns:
- the first node of the JSON response or null if exception is thrown
-
getFirstNode
public static com.fasterxml.jackson.databind.JsonNode getFirstNode(String text, String path)
Return the first node of a JSON response.- Parameters:
text- JSON textpath- path to find the first node- Returns:
- the first node of the JSON response or null if exception is thrown
-
getElement
public static Object getElement(com.fasterxml.jackson.databind.JsonNode json, String name)
Return the field with name in JSON as a string, a boolean, a number or a node.- Parameters:
json- jsonname- node name- Returns:
- the field
-
toJSONString
public static String toJSONString(Object obj)
Returns the JSON string for the object.- Parameters:
obj- the object- Returns:
- the JSON string
-
getMapper
public static com.fasterxml.jackson.databind.ObjectMapper getMapper()
-
-