com.groupdocs.assembly

Class JsonDataSource

  • java.lang.Object
    • com.groupdocs.assembly.JsonDataSource


  • public class JsonDataSource
    extends java.lang.Object
    Provides access to data of a JSON file or stream to be used while assembling a document.

    To access data of the corresponding file or stream while assembling a document, pass an instance of this class as a data source to one of DocumentAssembler. assembleDocument overloads.

    In template documents, if a top-level JSON element is an array, a JsonDataSource instance should be treated in the same way as if it was a DataTable instance. If a top-level JSON element is an object, a JsonDataSource instance should be treated in the same way as if it was a DataRow instance. For more information, see template syntax reference(https://docs.groupdocs.com/display/assemblyjava/Template+Syntax+-+Part+1+of+2#TemplateSyntax-Part1of2-UsingDataSources).

    In template documents, you can work with typed values of JSON elements. For convenience, the engine replaces the set of JSON simple types with the following one:

    • java.lang.Integer
    • java.lang.Long
    • java.lang.Double
    • java.lang.Boolean
    • java.util.Date
    • java.lang.String

    The engine automatically recognizes values of the extra types upon their JSON representations.

    To override default behavior of JSON data loading, initialize and pass a JsonDataLoadOptions instance to a constructor of this class.

    • Constructor Summary

      Constructors 
      Constructor and Description
      JsonDataSource(java.io.InputStream jsonStream)
      Creates a new data source with data from a JSON stream using default options for parsing JSON data.
      JsonDataSource(java.io.InputStream jsonStream, JsonDataLoadOptions options)
      Initializes a new instance of this class.
      JsonDataSource(java.lang.String jsonPath)
      Creates a new data source with data from a JSON file using default options for parsing JSON data.
      JsonDataSource(java.lang.String jsonPath, JsonDataLoadOptions options)
      Creates a new data source with data from a JSON file using the specified options for parsing JSON data.
    • Method Summary

      • Methods inherited from class java.lang.Object

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

      • JsonDataSource

        public JsonDataSource(java.lang.String jsonPath)
                       throws java.lang.Exception
        Creates a new data source with data from a JSON file using default options for parsing JSON data.
        Parameters:
        jsonPath - The path to the JSON file to be used as the data source.
        Throws:
        java.lang.Exception
      • JsonDataSource

        public JsonDataSource(java.lang.String jsonPath,
                              JsonDataLoadOptions options)
                       throws java.lang.Exception
        Creates a new data source with data from a JSON file using the specified options for parsing JSON data.
        Parameters:
        jsonPath - The path to the JSON file to be used as the data source.
        options - Options for parsing JSON data.
        Throws:
        java.lang.Exception
      • JsonDataSource

        public JsonDataSource(java.io.InputStream jsonStream)
                       throws java.lang.Exception
        Creates a new data source with data from a JSON stream using default options for parsing JSON data.
        Parameters:
        jsonStream - The stream of JSON data to be used as the data source.
        Throws:
        java.lang.Exception
      • JsonDataSource

        public JsonDataSource(java.io.InputStream jsonStream,
                              JsonDataLoadOptions options)
                       throws java.lang.Exception
        Initializes a new instance of this class.
        Throws:
        java.lang.Exception