Documentation

Overview

    Package data holds custom types and functions for passing JSON between ratchet stages.

    Index

    Examples

    Constants

    This section is empty.

    Variables

    This section is empty.

    Functions

    func ObjectsFromJSON

    func ObjectsFromJSON(d JSON) ([]map[string]interface{}, error)

      ObjectsFromJSON is a helper for parsing JSON into a slice of generic maps/objects. The use-case is when a stage is expecting to receive either a JSON object or an array of JSON objects, and want to deal with it in a generic fashion.

      Example
      Output:
      
      [map[One:1] map[Two:2]]
      

      func ParseJSON

      func ParseJSON(d JSON, v interface{}) error

        ParseJSON is a simple wrapper for json.Unmarshal

        Example
        Output:
        
        {A:1 B:2}
        

        func ParseJSONSilent

        func ParseJSONSilent(d JSON, v interface{}) error

          ParseJSONSilent won't log output when unmarshaling fails. It can be used in cases where failure is expected.

          Types

          type JSON

          type JSON []byte

            JSON is the data type that is passed along all data channels. Under the covers, JSON is simply a []byte containing JSON data.

            func JSONFromHeaderAndRows

            func JSONFromHeaderAndRows(header []string, rows [][]interface{}) (JSON, error)

              JSONFromHeaderAndRows takes the given header and rows of values, and turns it into a JSON array of objects.

              Example
              Output:
              
              [{"A":1,"B":2,"C":3},{"A":4,"B":5,"C":6}]
              

              func NewJSON

              func NewJSON(v interface{}) (JSON, error)

                NewJSON is a simple wrapper for json.Marshal.

                Example
                Output:
                
                {"A":1,"B":2}
                

                Source Files