Class JSONArrayUtils

java.lang.Object
com.nimbusds.jose.util.JSONArrayUtils

public class JSONArrayUtils extends Object
JSON array helper methods.
Version:
2024-11-14
Author:
Toma Velev, Vladimir Dzhuvinov
  • Method Details

    • parse

      public static List<Object> parse(String s) throws ParseException
      Parses a JSON array.

      Specific JSON to Java entity mapping (as per JSON Smart):

      • JSON true|false map to java.lang.Boolean.
      • JSON numbers map to java.lang.Number.
        • JSON integer numbers map to long.
        • JSON fraction numbers map to double.
      • JSON strings map to java.lang.String.
      • JSON arrays map to java.util.List<Object>.
      • JSON objects map to java.util.Map<String,Object>.
      Parameters:
      s - The JSON array string to parse. Must not be null.
      Returns:
      The JSON object.
      Throws:
      ParseException - If the string cannot be parsed to a valid JSON object.
    • toJSONString

      public static String toJSONString(List<?> jsonArray)
      Serialises the specified list to a JSON array using the entity mapping specified in parse(String).
      Parameters:
      jsonArray - The JSON array. Must not be null.
      Returns:
      The JSON array as string.
    • newJSONArray

      public static List<Object> newJSONArray()
      Creates a new JSON array.
      Returns:
      The new empty JSON array.