jsonwrap

package module
v0.0.0-...-ba2fc60 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

README

JSONWrap

godoc Build Status Go Report Card

jsonwrap provides a simple API for JSON object nesting in Go.

A convenience CLI app implementing the API and capable of forwarding the wrapped JSON to a remote HTTP endpoint is also provided.

CLI Quick Start

Using the default Consul service catalog as an example:

$ curl -X GET localhost:8500/v1/catalog/services
{
    "consul": []
}

This can be nested under as many levels as needed, simply repeat the --wrap flag for each level:

$ curl -s -X GET localhost:8500/v1/catalog/services | jsonwrap --wrap services --wrap consul
{
    "consul": {
        "services": {
            "consul": []
        }
    }
}

The wrapped output can, in turn, be forwarded to a remote HTTP endpoint:

$ curl -s -X GET localhost:8500/v1/catalog/services | \
  jsonwrap --wrap services --wrap consul --method PUT --target http://localhost:8181/v1/data

Usage

$ jsonwrap --help
NAME:
   jsonwrap - CLI for JSON object nesting and HTTP forwarding

USAGE:
    [global options] command [command options] <JSON file>

VERSION:
   0.0.1

DESCRIPTION:
   A convenience CLI tool for nesting JSON objects and forwarding the result to a remote HTTP endpoint

AUTHOR:
   Adaptant Labs <[email protected]>

COMMANDS:
   help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --target value  Target URL to forward wrapped JSON to
   --method value  Forwarding method to use (default: "POST")
   --wrap value    Name of object to nest under
   --help, -h      show help
   --version, -v   print the version

COPYRIGHT:
   (c) 2019 Adaptant Solutions AG

API Documentation

Online API documentation is provided through godoc, and can be accessed directly on the package entry in the godoc package repository.

Features and bugs

Please file feature requests and bugs at the issue tracker.

License

Licensed under the terms of the Apache 2.0 license, the full version of which can be found in the LICENSE file included in the distribution.

Documentation

Overview

Package jsonwrap provides a simple API for JSON object nesting.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONWrapper

type JSONWrapper struct {
	// Verify the provided JSON input string before attempting to wrap it
	Verify bool

	// Pretty-format the resulting JSON output
	Prettify bool
}

A JSONWrapper instance provides JSON wrapping functionality with specific formatting and verification options.

func NewJSONWrapper

func NewJSONWrapper() JSONWrapper

NewJSONWrapper instantiates a new JSONWrapper instance with the default configuration.

func (JSONWrapper) Wrap

func (j JSONWrapper) Wrap(parent string, child string) string

Wrap handles the actual wrapping of the complete child JSON string within the parent object.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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