Code Monkey home page Code Monkey logo

jstransform's Introduction

jstransform

Go Docs Build Status Go Report Card Coverage Status

This repo provides an extension to JSON Schema which defines a transform section which can be added for each field. This transform section is then used to guide a transformation process which converts JSON or XML input into the format defined by the schema. The result is that you can write one JSON schema that defines both the desired result and how to transform a known type of data into the defined result.

The code also provides some utilities for walking a JSON schema file section by section and generating Golang structs from a JSON schema file.

JSON Schema Transform extension

Details on this are found in this doc and this schema file

Usage

For details on using the project as a library for transformations or JSON schema walking refer to the godocs.

The Golang struct generation portion of this code based is intended to be used with go generate.

Go Generate Examples

To use the struct generation with go generate include a generate line in a go source file for example:

//go:generate go run ../../vendor/github.com/GannettDigital/jstransform/main.go myschema.json .

or if you have compiled the tool and have it in your path rather than vendoring the source:

//go:generate jstransform myschema.json .

then simply run go generate.

As well as generating Go structs serialization libraries for Message Pack and Avro are available. For Avro the schema as well as serialization and helper functions are generated. The Avro schema also adds two metadata fields, AvroWriteTime and AvroDeleted. The generated serialization functions are based these libraries:

Building/Testing

This project uses Go modules for dependency management. You need to have a working Go environment with version 1.11 or greater installed.

Testing is done using standard go tooling, ie go test ./...

jstransform's People

Contributors

tkuhlman avatar gannett-ggreer avatar ahornerr avatar abaehre avatar ikenticus avatar adilbozai1995 avatar jstorer avatar barberta avatar adamhostettler avatar zacaudette avatar johnkuhlin avatar scniro avatar mmandolesi-g avatar brianlieberman avatar athatch73 avatar dependabot[bot] avatar erikturner avatar dnguy078 avatar enigmatic00 avatar leowotzak avatar tomtoday avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.