Liquid XML Data Binder (C++, Java, VB6) / Reference / C# and VB .Net (Deprecated - use Liquid XML Objects) / Reference / XmlObjectBase / Liquid JSON Runtime for .Net - ToJsonFile - JsonObjectInterface
In This Topic
    Liquid JSON Runtime for .Net - ToJsonFile - JsonObjectInterface
    In This Topic
    void ToJsonFile(String FileName);
    void ToJsonFile(String FileName,
                               bool includeDocHeader,
                               Formatting formatting,
                               System.Text.Encoding encoding,
                               EOLType eol);
    void ToJsonFile(String FileName,
                               bool includeDocHeader,
                               Formatting formatting,
                               System.Text.Encoding encoding,
                               EOLType eol,
                               SerializationContext context);
      Property Description  
        Method Name ToJsonFile  
        Argument - filename The name of the file that will receive the xml  
        Argument - includeDocHeader (Default true) If this is true then then header <?xml version="1.0" ?> 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 true to turn on indenting, false for no formatting.  
        Argument - encoding (Default System.Text.UTF8Encoding()) The type of encoding to use when formating the JSON. UTF8, UTF16 & Unicode are options. UTF8 is default.  
        Argument - eol (Default EOLType.CRLF) Indicates the type of End of line token to use, LF or CRLF. Defaults to CRLF.  
        Argument - context

    The SerializationContext object controls the way in which JSON is serialized/de-serialized. Its main role is to control the way in which validation is performed and which namespaces are output.
    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.

    Note: 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 Writes JSON from the current object to a file  

    If the file already exists it is overwritten, if it does not exist it is created.
    It will raise an exception if the JSON within the object is not invalid, i.e. invalid number of entries in a collection.

    If the encoding is UTF-8 (the default) then the file is written out using the UTF-8 encoding scheme. It should be noted that UTF-8 encoding will encode  characters using 1-4 bytes. As such if the file is examined with a viewer that is not capable of decoding UTF-8, it will appear to contain odd characters. However if it is viewed with a compliant viewer (e.g. IExplorer) the file will appear as expected.
    See Multi-Language Support for more information.

    If the encoding selected is UNICODE, then the file is written out using 2 bytes per character. The standard 0xff 0xfe are placed at the beginning of the file to indicate to other applications that it is a UNICODE file.