flatjson

command module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2019 License: MIT Imports: 4 Imported by: 0

README

flatjson

Make JSON one level deep

Description

flatjson is a utility to normalize JSON files. Given a JSON object or an array it will return an array of JSON objects one level deep, enriched with additional properties that establish the original relation.

Installation

flatjson is available using the standard go get command.

Install by running:

go get github.com/cbhvn/flatjson

Example usage

>echo [{"a":{"b":"c"}}, {"d":"e","f":{"g":"h"}}] | flatjson
[
  {
    "_id": 2,
    "_parentid": 1,
    "_parentref": ""
  },
  {
    "_id": 3,
    "_parentid": 2,
    "_parentref": "a",
    "b": "c"
  },
  {
    "_id": 4,
    "_parentid": 1,
    "_parentref": "",
    "d": "e"
  },
  {
    "_id": 5,
    "_parentid": 4,
    "_parentref": "f",
    "g": "h"
  }
]

Usage

>flatjson --help
Usage of flatjson.exe:
  -f, --file string       input file
      --id int            begin id numbering with (default 1)
  -o, --output string     output file
      --parentid string   parent id property name (default "_parentid")
      --propid string     id property name (default "_id")
      --ref string        parent ref property name (default "_parentref")

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL