Class JSONParser

java.lang.Object
org.apache.felix.utils.json.JSONParser

public class JSONParser extends Object
A very small JSON parser. The JSON input is parsed into an object structure in the following way:
  • Object names are represented as a String.
  • String values are represented as a String.
  • Numeric values without a decimal separator are represented as a Long.
  • Numeric values with a decimal separator are represented as a Double.
  • Boolean values are represented as a Boolean.
  • Nested JSON objects are parsed into a Map<String, Object>.
  • JSON lists are parsed into a List which may contain any of the above values.
  • Field Details

    • KEY_VALUE_PATTERN

      private static final Pattern KEY_VALUE_PATTERN
    • parsed

      private final Object parsed
  • Constructor Details

  • Method Details

    • getParsed

      public Map<String,Object> getParsed()
    • getParsedList

      public List<Object> getParsedList()
    • parseKeyValue

      private static JSONParser.Pair<String,Object> parseKeyValue(String jsonKeyValue)
    • parseValue

      private static Object parseValue(String jsonValue)
    • unEscapeString

      private static String unEscapeString(String s)
    • parseObject

      private static Object parseObject(String jsonObject)
    • parseKeyValueListRaw

      private static List<String> parseKeyValueListRaw(String jsonKeyValueList)
    • parseListValuesRaw

      private static List<String> parseListValuesRaw(String jsonList)
    • readStream

      private static byte[] readStream(InputStream is) throws IOException
      Read an entire input stream into a byte array.
      Parameters:
      is - The input stream to read.
      Returns:
      The byte array with the contents of the input stream.
      Throws:
      IOException - if the underlying read operation on the input stream throws an error.
    • readStreamAsString

      private static String readStreamAsString(InputStream is) throws IOException
      Throws:
      IOException