Class JSONKt

  • All Implemented Interfaces:

    
    public final class JSONKt
    
                        
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final static <T extends Any> T to(String $self) Parses the json string as TE.g.
      final static <T extends Any> T to(ByteArray $self) Parses the json byte array as TE.g.
      final static <T extends Any> T to(URL $self, JSONReader.Feature features) Parses the json stream as T with the specified featuresE.g.
      final static <T extends Any> T to(InputStream $self, JSONReader.Feature features) Parses the json stream as T with the specified featuresE.g.
      final static <T extends Any> T into(String $self) Parses the json string as T Implemented using TypeReferenceE.g.
      final static <T extends Any> T into(ByteArray $self) Parses the json byte array as T Implemented using TypeReferenceE.g.
      final static <T extends Any> T into(URL $self, JSONReader.Feature features) Parses the json stream as T with the specified featuresE.g.
      final static <T extends Any> T into(InputStream $self, JSONReader.Feature features) Parses the json stream as T with the specified featuresE.g.
      final static Boolean isJSONObject(String $self) Verify that the json string is a JsonObjectE.g.
      final static Boolean isJSONObject(ByteArray $self) Verify that the json byte array is a JsonObjectE.g.
      final static Boolean isJSONArray(String $self) Verify that the json string is a JsonArrayE.g.
      final static Boolean isJSONArray(ByteArray $self) Verify that the json byte array is a JsonArrayE.g.
      final static JSONObject parseObject(String $self) Parses the json string as JSONObjectE.g.
      final static JSONObject parseObject(ByteArray $self) Parses the json byte array as JSONObjectE.g.
      final static JSONObject parseObject(String $self, JSONReader.Feature features) Parses the json string as JSONObject with the specified features
      final static JSONObject parseObject(ByteArray $self, JSONReader.Feature features) Parses the json byte array as JSONObject with the specified features
      final static JSONObject parseObject(Reader $self, JSONReader.Feature features) Parses the json reader as JSONObject with the specified features
      final static JSONObject parseObject(InputStream $self, JSONReader.Feature features) Parses the json stream as JSONObject with the specified features
      final static <T extends Any> T parseObject(String $self) Parses the json string as T
      final static <T extends Any> T parseObject(String $self, JSONReader.Feature features) Parses the json string as T with the specified features
      final static <T extends Any> T parseObject(String $self, Filter filter, JSONReader.Feature features) Parses the json string as T with the specified filter and features
      final static <T extends Any> T parseObject(ByteArray $self) Parses the json byte array as T
      final static <T extends Any> T parseObject(ByteArray $self, JSONReader.Feature features) Parses the json byte array as T with the specified features
      final static <T extends Any> T parseObject(ByteArray $self, Filter filter, JSONReader.Feature features) Parses the json byte array as T with the specified filter and features
      final static <T extends Any> T parseObject(ByteArray $self, Integer offset, Integer length, Charset charset) Parses the json byte array as T with the specified offset, length and charset
      final static <T extends Any> Unit parseObject(Reader $self, Character delimiter, Function1<T, Unit> consumer) Parses the json reader as T with the specified delimiter and consumerE.g.
      final static <T extends Any> Unit parseObject(InputStream $self, JSONReader.Feature features, Function1<T, Unit> consumer) Parses the json stream as T with the specified features and consumerE.g.
      final static <T extends Any> Unit parseObject(InputStream $self, Charset charset, Character delimiter, JSONReader.Feature features, Function1<T, Unit> consumer) Parses the json stream as T with the specified charset and features and so onE.g.
      final static JSONArray parseArray(String $self) Parses the json string as JSONArrayE.g.
      final static <T extends Any> List<T> parseArray(String $self) Parses the json string as a list of TE.g.
      final static <T extends Any> List<T> parseArray(String $self, JSONReader.Feature features) Parses the json string as a list of T with the specified features
      final static <T extends Any> List<T> parseArray(ByteArray $self, JSONReader.Feature features) Parses the json byte array as a list of T with the specified features
      final static String toJSONString(Object $self) Serializes this object to the json stringE.g.
      final static String toJSONString(Object $self, Array<out Filter> filters) Serializes this object to the json string with the specified filters
      final static String toJSONString(Object $self, JSONWriter.Feature features) Serializes this object to the json string with the specified features
      final static String toJSONString(Object $self, Filter filter, JSONWriter.Feature features) Serializes this object to the json string with the specified filter and features
      final static String toJSONString(Object $self, Array<out Filter> filters, JSONWriter.Feature features) Serializes this object to the json string with the specified filters and features
      final static ByteArray toJSONByteArray(Object $self) Serializes this object to the json byte arrayE.g.
      final static ByteArray toJSONByteArray(Object $self, Array<out Filter> filters) Serializes this object to the json byte array with the specified filters
      final static ByteArray toJSONByteArray(Object $self, JSONWriter.Feature features) Serializes this object to the json byte array with the specified features
      final static ByteArray toJSONByteArray(Object $self, Array<out Filter> filters, JSONWriter.Feature features) Serializes this object to the json byte array with the specified filters and features
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • to

         final static <T extends Any> T to(String $self)

        Parses the json string as T

        E.g.

        val json = ...
        val data = json.to<User>()
        Returns:

        T?

        Since:

        2.0.3

      • to

         final static <T extends Any> T to(ByteArray $self)

        Parses the json byte array as T

        E.g.

        val json = ...
        val data = json.to<User>()
        Returns:

        T?

        Since:

        2.0.3

      • to

         final static <T extends Any> T to(URL $self, JSONReader.Feature features)

        Parses the json stream as T with the specified features

        E.g.

        val url = ...
        val data = url.to<User>()
        Parameters:
        features - the specified features is applied to parsing
        Returns:

        T?

        Since:

        2.0.30

      • to

         final static <T extends Any> T to(InputStream $self, JSONReader.Feature features)

        Parses the json stream as T with the specified features

        E.g.

        val in = ...
        val data = in.to<User>()
        Parameters:
        features - the specified features is applied to parsing
        Returns:

        T?

        Since:

        2.0.4

      • into

         final static <T extends Any> T into(String $self)

        Parses the json string as T Implemented using TypeReference

        E.g.

        val json = ...
        val data = json.into<Map<String, User>>()
        Returns:

        T?

        Since:

        2.0.3

      • into

         final static <T extends Any> T into(ByteArray $self)

        Parses the json byte array as T Implemented using TypeReference

        E.g.

        val json = ...
        val data = json.into<Map<String, User>>()
        Returns:

        T?

        Since:

        2.0.3

      • into

         final static <T extends Any> T into(URL $self, JSONReader.Feature features)

        Parses the json stream as T with the specified features

        E.g.

        val url = ...
        val data = url.into<Map<String, User>>()
        Parameters:
        features - the specified features is applied to parsing
        Returns:

        T?

        Since:

        2.0.4

      • into

         final static <T extends Any> T into(InputStream $self, JSONReader.Feature features)

        Parses the json stream as T with the specified features

        E.g.

        val in = ...
        val data = in.into<Map<String, User>>()
        Parameters:
        features - the specified features is applied to parsing
        Returns:

        T?

        Since:

        2.0.4

      • isJSONObject

         final static Boolean isJSONObject(String $self)

        Verify that the json string is a JsonObject

        E.g.

        val json = ...
        val bool = json.isJSONObject()
        Since:

        2.0.3

      • isJSONObject

         final static Boolean isJSONObject(ByteArray $self)

        Verify that the json byte array is a JsonObject

        E.g.

        val json = ...
        val bool = json.isJSONObject()
        Since:

        2.0.3

      • isJSONArray

         final static Boolean isJSONArray(String $self)

        Verify that the json string is a JsonArray

        E.g.

        val json = ...
        val bool = json.isJSONArray()
        Since:

        2.0.3

      • isJSONArray

         final static Boolean isJSONArray(ByteArray $self)

        Verify that the json byte array is a JsonArray

        E.g.

        val json = ...
        val bool = json.isJSONArray()
        Since:

        2.0.3

      • parseObject

         final static JSONObject parseObject(String $self)

        Parses the json string as JSONObject

        E.g.

        val json = ...
        val data = json.parseObject()
        Returns:

        JSONObject?

        Since:

        2.0.3

      • parseObject

         final static JSONObject parseObject(ByteArray $self)

        Parses the json byte array as JSONObject

        E.g.

        val json = ...
        val data = json.parseObject()
        Returns:

        JSONObject?

        Since:

        2.0.4

      • parseObject

         final static JSONObject parseObject(String $self, JSONReader.Feature features)

        Parses the json string as JSONObject with the specified features

        Parameters:
        features - the specified features is applied to parsing
        Returns:

        JSONObject?

        Since:

        2.0.4

      • parseObject

         final static JSONObject parseObject(ByteArray $self, JSONReader.Feature features)

        Parses the json byte array as JSONObject with the specified features

        Parameters:
        features - the specified features is applied to parsing
        Returns:

        JSONObject?

        Since:

        2.0.4

      • parseObject

         final static JSONObject parseObject(Reader $self, JSONReader.Feature features)

        Parses the json reader as JSONObject with the specified features

        Parameters:
        features - the specified features is applied to parsing
        Returns:

        JSONObject?

        Since:

        2.0.30

      • parseObject

         final static JSONObject parseObject(InputStream $self, JSONReader.Feature features)

        Parses the json stream as JSONObject with the specified features

        Parameters:
        features - the specified features is applied to parsing
        Returns:

        JSONObject?

        Since:

        2.0.4

      • parseObject

         final static <T extends Any> T parseObject(String $self)

        Parses the json string as T

        Returns:

        T?

        Since:

        2.0.3

      • parseObject

         final static <T extends Any> T parseObject(String $self, JSONReader.Feature features)

        Parses the json string as T with the specified features

        Parameters:
        features - the specified features is applied to parsing
        Returns:

        T?

        Since:

        2.0.3

      • parseObject

         final static <T extends Any> T parseObject(String $self, Filter filter, JSONReader.Feature features)

        Parses the json string as T with the specified filter and features

        Parameters:
        filter - the specified filter is applied to parsing
        features - the specified features is applied to parsing
        Returns:

        T?

        Since:

        2.0.3

      • parseObject

         final static <T extends Any> T parseObject(ByteArray $self)

        Parses the json byte array as T

        Returns:

        T?

        Since:

        2.0.3

      • parseObject

         final static <T extends Any> T parseObject(ByteArray $self, JSONReader.Feature features)

        Parses the json byte array as T with the specified features

        Parameters:
        features - the specified features is applied to parsing
        Returns:

        T?

        Since:

        2.0.30

      • parseObject

         final static <T extends Any> T parseObject(ByteArray $self, Filter filter, JSONReader.Feature features)

        Parses the json byte array as T with the specified filter and features

        Parameters:
        filter - the specified filter is applied to parsing
        features - the specified features is applied to parsing
        Returns:

        T?

        Since:

        2.0.30

      • parseObject

         final static <T extends Any> T parseObject(ByteArray $self, Integer offset, Integer length, Charset charset)

        Parses the json byte array as T with the specified offset, length and charset

        Returns:

        T?

        Since:

        2.0.3

      • parseObject

         final static <T extends Any> Unit parseObject(Reader $self, Character delimiter, Function1<T, Unit> consumer)

        Parses the json reader as T with the specified delimiter and consumer

        E.g.

        val reader = ...
        reader.parseObject<User>() {
            val id = it.id
        }
        Parameters:
        delimiter - the specified delimiter is used to distinguish
        Since:

        2.0.3

      • parseObject

         final static <T extends Any> Unit parseObject(InputStream $self, JSONReader.Feature features, Function1<T, Unit> consumer)

        Parses the json stream as T with the specified features and consumer

        E.g.

        val input = ...
        input.parseObject<User> {
            val id = it.id
        }
        Parameters:
        features - the specified features is applied to parsing
        consumer - the specified consumer is applied to parsing
        Since:

        2.0.3

      • parseObject

         final static <T extends Any> Unit parseObject(InputStream $self, Charset charset, Character delimiter, JSONReader.Feature features, Function1<T, Unit> consumer)

        Parses the json stream as T with the specified charset and features and so on

        E.g.

        val input = ...
        input.parseObject<User>(Charsets.UTF_8) {
            val id = it.id
        }
        Parameters:
        charset - the specified charset of the stream
        delimiter - the specified delimiter is used to distinguish
        features - the specified features is applied to parsing
        consumer - the specified consumer is applied to parsing
        Since:

        2.0.3

      • parseArray

         final static JSONArray parseArray(String $self)

        Parses the json string as JSONArray

        E.g.

        val json = ...
        val data = json.parseArray()
        Returns:

        JSONArray?

        Since:

        2.0.3

      • parseArray

         final static <T extends Any> List<T> parseArray(String $self)

        Parses the json string as a list of T

        E.g.

        val json = ...
        val list = json.parseArray<User>()
        Returns:

        List?

        Since:

        2.0.3

      • parseArray

         final static <T extends Any> List<T> parseArray(String $self, JSONReader.Feature features)

        Parses the json string as a list of T with the specified features

        Parameters:
        features - the specified features is applied to parsing
        Returns:

        List?

        Since:

        2.0.3

      • parseArray

         final static <T extends Any> List<T> parseArray(ByteArray $self, JSONReader.Feature features)

        Parses the json byte array as a list of T with the specified features

        Parameters:
        features - the specified features is applied to parsing
        Returns:

        List?

        Since:

        2.0.3

      • toJSONString

         final static String toJSONString(Object $self)

        Serializes this object to the json string

        E.g.

        val obj = ...
        val text = obj.toJSONString()
        Returns:

        String

        Since:

        2.0.3

      • toJSONString

         final static String toJSONString(Object $self, Array<out Filter> filters)

        Serializes this object to the json string with the specified filters

        Parameters:
        filters - the specified filters is applied to serialization
        Returns:

        String

        Since:

        2.0.3

      • toJSONString

         final static String toJSONString(Object $self, JSONWriter.Feature features)

        Serializes this object to the json string with the specified features

        Parameters:
        features - the specified features is applied to serialization
        Returns:

        String

        Since:

        2.0.3

      • toJSONString

         final static String toJSONString(Object $self, Filter filter, JSONWriter.Feature features)

        Serializes this object to the json string with the specified filter and features

        Parameters:
        filter - the specified filter is applied to serialization
        features - the specified features is applied to serialization
        Returns:

        String

        Since:

        2.0.3

      • toJSONString

         final static String toJSONString(Object $self, Array<out Filter> filters, JSONWriter.Feature features)

        Serializes this object to the json string with the specified filters and features

        Parameters:
        filters - the specified filters is applied to serialization
        features - the specified features is applied to serialization
        Returns:

        String

        Since:

        2.0.3

      • toJSONByteArray

         final static ByteArray toJSONByteArray(Object $self)

        Serializes this object to the json byte array

        E.g.

        val obj = ...
        val text = obj.toJSONByteArray()
        Returns:

        ByteArray

        Since:

        2.0.3

      • toJSONByteArray

         final static ByteArray toJSONByteArray(Object $self, Array<out Filter> filters)

        Serializes this object to the json byte array with the specified filters

        Parameters:
        filters - the specified filters is applied to serialization
        Returns:

        ByteArray

        Since:

        2.0.3

      • toJSONByteArray

         final static ByteArray toJSONByteArray(Object $self, JSONWriter.Feature features)

        Serializes this object to the json byte array with the specified features

        Parameters:
        features - the specified features is applied to serialization
        Returns:

        ByteArray

        Since:

        2.0.3

      • toJSONByteArray

         final static ByteArray toJSONByteArray(Object $self, Array<out Filter> filters, JSONWriter.Feature features)

        Serializes this object to the json byte array with the specified filters and features

        Parameters:
        filters - the specified filters is applied to serialization
        features - the specified features is applied to serialization
        Returns:

        ByteArray

        Since:

        2.0.3