Liquid XML Data Binder 2020
Liquid XML Data Binder (C++, Java, VB6) / Reference / Java / Reference / com.liquid_technologies.ltxmllib18 / XmlObjectBase / Java toJsonStream - JsonObjectInterface
In This Topic
    Java toJsonStream - JsonObjectInterface
    In This Topic

    public final byte[] toJsonStream()
                throws LtException,
                             IOException

    public final byte[] toJsonStream( boolean includeDocHeader,
                
                                                 Formatting formatting,
                
                                                 Encoding encoding,
                
                                                 EOLType EOL)
                
    throws LtException,
                
                 UnsupportedEncodingException,
                
                 IOException

    public final byte[] toJsonStream(boolean includeDocHeader,
                
                                                Formatting formatting,
                
                                                Encoding encoding,
                
                                                EOLType EOL,
                
                                                com.liquid_technologies.ltxmllib18.SerializationContext context)
                
    throws LtException,
                
                 UnsupportedEncodingException,
                
                 IOException

      Property Description  
        Method Name ToJsonStream  
        Return The JSON data contained in the object as a byte array  
        Argument - includeDocHeader Default true. If this is true then then header <?xml version="1.0" standalone="yes"?> is applied to the output (making it a proper JSON document as opposed to a snippet).  
        Argument - formatting Default Formatting.Indented. Indicates how the JSON should be formatted  
        Argument - encoding Default Encoding.UTF8. Allows you to change the encoding used (UTF8, UTF16 etc)  
    Argument - EOL Default EOLType.CRLF. Allows you to change the Eond Of Line token (CR for unix or CRLF windows)
        Argument - context The SerializationContext
    If this is not specified, the a default (SerializationContext.Default global static) instance of the class is used. If you are using several libraries generated from different schemas, or you want to change the way validation is performed for during the lifetime of the application or you are writing multithreaded code, then you should consider creating your own instance(s) of the SerializationContext.
    If you are writing a multithreaded app it is highly recommended that you use a different instance of this class on each thread, as access to the static instance is not synchronized. Although read only operations to the static instance (SerializationContext.Default) of the class are thread safe, if the global instance SerializationContext.Default is modified, then this could potentially cause threading problems.
     
        Description Returns a byte array containing the JSON.  
        Remarks

    It will raise an exception if the JSON within the object is not invalid, i.e. invalid number of entries in a collection.

    The function returns a UNICODE xml string. This means that the document header (if included) will contain just <?xml version="1.0"?>. If 'exotic' characters have been used they will simply be encoded as UNICODE.
    It should be noted that, if the string is converted to a single byte representation (1 byte per character) for transmission or writing to disk, then there is a danger that characters will be misrepresented.
    See Multi-Language Support for more information.