Class Json

    • Constructor Detail

      • Json

        public Json()
    • Method Detail

      • encode

        public static String encode​(Object object,
                                    Json.Option... options)
        Encodes the given object as JSON and returns a string in JSON format. The encoded object will be available as data property of the JS object in the returned JSON string.
        Parameters:
        object - The object to be encoded as JSON.
        options - The encoding options.
        Returns:
        The JSON-encoded representation of the given object.
        Throws:
        IllegalArgumentException - When given object or one of its properties cannot be inspected as a JavaBean.
      • encode

        public static void encode​(Object object,
                                  Writer writer,
                                  Json.Option... options)
        Encodes the given object as JSON while streaming the string in JSON format to the given writer. The encoded object will be available as data property of the JS object in the returned JSON string.
        Parameters:
        object - The object to be encoded as JSON.
        writer - The writer to stream the encoded output to.
        options - The encoding options.
        Throws:
        IllegalArgumentException - When given object or one of its properties cannot be inspected as a JavaBean.