PKuebler / pigeon-go

A JSON patch module to exchange data compatible with the JS Package Pigeon. https://github.com/frameable/pigeon

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pigeon-Go codecov

A JSON patch module to exchange data compatible with the JS Package Pigeon.

Production ready?

No, this is a very early unfinished version. Please use with caution.

Example

package main

import (
    "fmt"
    pigeongo "github.com/pkuebler/pigeon-go"
)

func main() {
    doc := pigeongo.NewDocument([]byte(`{ "name": "Philipp" }`))

    doc.ApplyChanges(Changes{
		Diff: []Operation{
			{
				Op:    "replace",
				Path:  "/name",
				Value: rawMessage(`"Phil"`),
				Prev:  rawMessage(`"Philipp"`),
			},
		},
		Ts:  2,
		Cid: "50reifj9hyt",
		Gid: "dva96nqsdd",
	})

    // Print JSON
    fmt.Println(doc.JSON)
    // Print Warnings
    fmt.Println(doc.Warning)
}

Custom Identifier

pigeongo.NewDocument([]byte(`[{ "attrs": { "id": 123 }, "name": "Philipp" }]`), pigeongo.WithCustomIdentifier([][]string{{"id"},{"attrs", "id"}}))

About

A JSON patch module to exchange data compatible with the JS Package Pigeon. https://github.com/frameable/pigeon

License:MIT License


Languages

Language:Go 100.0%