Class InsertJsonObject

  • All Implemented Interfaces:
    AdaptrisComponent, ComponentLifecycle, ComponentLifecycleExtension, ConnectedService, MessageEventGenerator, Service, StateManagedComponent
    Direct Known Subclasses:
    InsertJsonObjects

    @ComponentProfile(summary="Insert a JSON object into a database",
                      tag="service,json,jdbc",
                      since="3.6.5")
    public class InsertJsonObject
    extends JdbcMapInsert
    Convenience service for inserting a JSON object into a database.

    Creates an insert statement based on the contents of the JSON object inside the array. { "firstname":"carol", "lastname":"smith", "dob":"2017-01-03" } will effectively execute the following statement INSERT INTO table (firstname,lastname,dob) VALUES (?,?,?).

    Note that no parsing/assertion of the column names will be done, so if they are invalid SQL columns then it's going to be fail. Additionally, nested JSON objects will be rendered as strings before being passed into the appropriate statement; so { "firstname":"alice", "lastname":"smith", "address": { "address" : "Buckingham Palace", "postcode":"SW1A 1AA"}} would still be 3 parameters, the address parameter will be '{ "address" : "Buckingham Palace", "postcode":"SW1A 1AA"}'

    Since:
    3.6.5

    In the adapter configuration file this class is aliased as json-jdbc-insert which is the preferred alternative to the fully qualified classname when building your configuration.

    • Constructor Detail

      • InsertJsonObject

        public InsertJsonObject()
    • Method Detail

      • getNullConverter

        public NullConverter getNullConverter()
        Returns:
        the nullConverter
      • setNullConverter

        public void setNullConverter​(NullConverter nc)
        Specify the behaviour when a NullNode is encountered.
        Parameters:
        nc - the NullConverter to set, the default is effectively the string "null" as returned by NullNode#asText()