Class JsonUtils

java.lang.Object
net.javacrumbs.jsonunit.core.internal.JsonUtils

public class JsonUtils
extends Object
Internal utility class to parse JSON values.
  • Constructor Details

  • Method Details

    • convertToJson

      public static Node convertToJson​(Object source, String label)
      Converts object to JSON.
      Parameters:
      source -
      label - label to be logged in case of error.
      Returns:
    • convertToJson

      public static Node convertToJson​(Object source, String label, boolean lenient)
      Converts object to JSON.
      Parameters:
      source -
      label - label to be logged in case of error.
      lenient - lenient parser used for expected values. Allows unquoted keys.
      Returns:
    • valueToNode

      public static Node valueToNode​(Object source)
      Converts value to Json node. It can be Map, String, null, or primitive. Should not be parsed, just converted.
      Parameters:
      source -
      Returns:
    • getNode

      public static Node getNode​(Object root, String path)
      Returns node with given path.
      Parameters:
      root -
      path -
      Returns:
    • getNode

      public static Node getNode​(Object root, Path path)
      Returns node with given path.
      Parameters:
      root -
      path -
      Returns:
    • nodeExists

      @Deprecated public static boolean nodeExists​(Object json, String path)
      Deprecated.
      Returns true if the node exists.
    • nodeAbsent

      public static boolean nodeAbsent​(Object json, String path, Configuration configuration)
    • nodeAbsent

      public static boolean nodeAbsent​(Object json, Path path, Configuration configuration)
    • jsonSource

      public static Object jsonSource​(Object json, String pathPrefix)
    • getPathPrefix

      public static String getPathPrefix​(Object json)
    • wrapDeserializedObject

      public static Node wrapDeserializedObject​(Object source)
      Wraps deserialized object - supports null, String, numbers, maps, lists, ...
    • missingNode

      public static Object missingNode()