jstransform

command module
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2024 License: MIT Imports: 7 Imported by: 0

README

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 ./...

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package generate implements a tooling to generate Golang structs from a JSON schema file.
Package generate implements a tooling to generate Golang structs from a JSON schema file.
avro_test_data/avro/arrays
Code generated by github.com/actgardner/gogen-avro.
Code generated by github.com/actgardner/gogen-avro.
avro_test_data/avro/complex
Code generated by github.com/actgardner/gogen-avro.
Code generated by github.com/actgardner/gogen-avro.
avro_test_data/avro/nested
Code generated by github.com/actgardner/gogen-avro/v7.
Code generated by github.com/actgardner/gogen-avro/v7.
avro_test_data/avro/repeats
Code generated by github.com/actgardner/gogen-avro.
Code generated by github.com/actgardner/gogen-avro.
avro_test_data/avro/simple
Code generated by github.com/actgardner/gogen-avro.
Code generated by github.com/actgardner/gogen-avro.
avro_test_data/avro/times
Code generated by github.com/actgardner/gogen-avro.
Code generated by github.com/actgardner/gogen-avro.
avro_test_data/avro/timespointers
Code generated by github.com/actgardner/gogen-avro.
Code generated by github.com/actgardner/gogen-avro.
avro_test_data/nonest/avro/complex
Code generated by github.com/actgardner/gogen-avro.
Code generated by github.com/actgardner/gogen-avro.
avro_test_data/nonest/avro/nested
Code generated by github.com/actgardner/gogen-avro.
Code generated by github.com/actgardner/gogen-avro.
avro_test_data/nonest/avro/simple
Code generated by github.com/actgardner/gogen-avro.
Code generated by github.com/actgardner/gogen-avro.
avro_test_data/pointers/avro/complex
Code generated by github.com/actgardner/gogen-avro.
Code generated by github.com/actgardner/gogen-avro.
avro_test_data/pointers/avro/nested
Code generated by github.com/actgardner/gogen-avro.
Code generated by github.com/actgardner/gogen-avro.
avro_test_data/pointers/avro/simple
Code generated by github.com/actgardner/gogen-avro.
Code generated by github.com/actgardner/gogen-avro.
avro_test_data/pointers/avro/times
Code generated by github.com/actgardner/gogen-avro.
Code generated by github.com/actgardner/gogen-avro.
Package jsonschema includes tools for walking JSON schema files and running a custom function for each instance.
Package jsonschema includes tools for walking JSON schema files and running a custom function for each instance.
Package transform implements code which can use a JSON schema with transform sections to convert a JSON file to match the schema format.
Package transform implements code which can use a JSON schema with transform sections to convert a JSON file to match the schema format.

Jump to

Keyboard shortcuts

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