Arbitrary transformations of JSON in Golang

golang, json, json-data, json-format, jsonpath, transformations
go get



Travis Build Status Coverage Status MIT licensed GitHub release GoDoc


Kazaam was created with the goal of supporting easy and fast transformations of JSON data with Golang. This functionality provides us with an easy mechanism for taking intermediate JSON message representations and transforming them to formats required by arbitrary third-party APIs.

Inspired by Jolt, Kazaam supports JSON to JSON transformation via a transform "specification" also defined in JSON. A specification is comprised of one or more "operations". See Specification Support, below, for more details.


API Documentation is available at

Specification Support

Kazaam currently supports the following transforms:

  • shift
  • default
  • pass


The shift transform is the current Kazaam workhorse used for remapping of fields. The specification supports jsonpath-esque JSON accesses and sets. Concretely

  "operation": "shift",
  "spec": {
    "": "doc.uid",
    "gid2": "doc.guid[1]",
    "allGuids": "doc.guidObjects[*].id"

executed on a JSON message with format

  "doc": {
    "uid": 12345,
    "guid": ["guid0", "guid2", "guid4"]
    "guidObjects": [{"id": "guid0"}, {"id": "guid2"}, {"id": "guid4"}]
  "top-level-key": null

would result in

  "object": {
    "id": 12345
  "gid2": "guid2",
  "allGuids": ["guid0", "guid2", "guid4"]

The jsonpath implementation supports a few special cases:

  • Array accesses: Retrieve nth element from array
  • Array wildcarding: indexing an array with [*] will return every matching element in an array
  • Top-level object capture: Mapping $ into a field will nest the entire original object under the requested key


A default transform provides the ability to set a key's value explicitly. For example

  "operation": "default",
  "spec": {
    "type": "message"

would ensure that the output JSON message includes {"type": "message"}.


A pass transform, as the name implies, passes the input data unchanged to the output. This is used internally when a null transform spec is specified, but may also be useful for testing.


To start, go get the versioned repository::

go get


See godoc examples.