Package org.pac4j.oauth.profile
Class JsonHelper
java.lang.Object
org.pac4j.oauth.profile.JsonHelper
This class is an helper to work with JSON.
- Since:
- 1.0.0
- Author:
- Jerome Leleu
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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.ObjectMapperGetter for the fieldmapper.static StringtoJSONString(Object obj) Returns the JSON string for the object.
-
Method Details
-
getFirstNode
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
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
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
Returns the JSON string for the object.- Parameters:
obj- the object- Returns:
- the JSON string
-
getMapper
public static com.fasterxml.jackson.databind.ObjectMapper getMapper()Getter for the field
mapper.- Returns:
- a
ObjectMapperobject
-