From b4c9a0ff6a2a69e281026f4617ea1795ca80871d Mon Sep 17 00:00:00 2001 From: mcei Date: Thu, 8 Feb 2024 21:02:45 +0700 Subject: [PATCH 1/2] Update README --- README.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 0e7d567..7b49605 100644 --- a/README.md +++ b/README.md @@ -3,13 +3,13 @@ [![Go](https://github.com/cyberstudio/jsonj/actions/workflows/go.yml/badge.svg)](https://github.com/cyberstudio/jsonj/actions/workflows/go.yml) [![GoDoc](https://godoc.org/github.com/cyberstudio/jsonj?status.svg)](https://godoc.org/github.com/cyberstudio/jsonj) [![Go Report Card](https://goreportcard.com/badge/github.com/cyberstudio/jsonj)](https://goreportcard.com/report/github.com/cyberstudio/jsonj) JSONJ can be used to manipulate raw json input using _marks_ and custom _fragments generators_. -* Library guarantees valid json output syntax; -* Library doesn't validate output json semantic like unique keys. +* Library guarantees a valid json output syntax; +* Library doesn't validate an output json semantic like unique keys. ## Marks -One can apply generator to _marks_ of json input. Each _mark_ is json key name. -For example, `uuid` and `id` maybe used as _mark_. +One can apply generator to _marks_ of json input. Each _mark_ is a json key name. +For example, `uuid` and `id` can be used as _mark_. ```json [ { @@ -23,26 +23,26 @@ For example, `uuid` and `id` maybe used as _mark_. ] ``` -_Mark_ maybe renamed in result of _operation_. It depends on `operation` mode and its rules. +_Mark_ can be renamed in result of _operation_. It depends on `operation` mode and its rules. -Advice: wrap _marks_ by special chars, i.e. `__uuid__` and unwrap during `operation`. +Advice: wrap _marks_ in special symbols, i.e. `__uuid__` and unwrap during `operation`. ## Operations -Library supports number of operations, named _Mode_: +The library supports a number of operations, named _Mode_: * `ModeInsert`: insert key/value pair after the _mark_. - * `ModeReplaceValue`: replace value, or convert it; + * `ModeReplaceValue`: replace or convert value; * `ModeReplace`: replace entire key/value pair; * `ModeDelete`: delete key/value. ## Fragments generators -Type `GenerateFragmentBatchFunc` describes interface of generators. -Key feature of generators is batch processing. Batches speed up result output. +Type `GenerateFragmentBatchFunc` describes an interface of generators. +Batch processing is a key feature of generators. Batches speed up the result output. Example: ```go -// GeneratorParams customize generator behavior +// GeneratorParams customizes generator behavior type GeneratorParams struct{ EmbedObjectURL bool BaseURL string From b0bcf938f053ca66262ca1a9911cd3fe6ffb3329 Mon Sep 17 00:00:00 2001 From: mcei Date: Fri, 16 Feb 2024 01:17:40 +0700 Subject: [PATCH 2/2] Update README. Review 1 --- README.md | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 7b49605..49ba63d 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,16 @@ [![Go](https://github.com/cyberstudio/jsonj/actions/workflows/go.yml/badge.svg)](https://github.com/cyberstudio/jsonj/actions/workflows/go.yml) [![GoDoc](https://godoc.org/github.com/cyberstudio/jsonj?status.svg)](https://godoc.org/github.com/cyberstudio/jsonj) [![Go Report Card](https://goreportcard.com/badge/github.com/cyberstudio/jsonj)](https://goreportcard.com/report/github.com/cyberstudio/jsonj) -JSONJ can be used to manipulate raw json input using _marks_ and custom _fragments generators_. -* Library guarantees a valid json output syntax; -* Library doesn't validate an output json semantic like unique keys. +The library seeks for marks in input json and applies fragment generators, producing a new json. +It works with rules that are combinations or marks and generators. + +The library guarantees a valid output json syntax on valid input json. +Also, it is possible to generate a semantically invalid json if fragment generators are not correct. +For example, an incorrect fragment generator can produce duplicate object keys. ## Marks -One can apply generator to _marks_ of json input. Each _mark_ is a json key name. +Each _mark_ is an object key name. One can apply generator to _marks_ of input. For example, `uuid` and `id` can be used as _mark_. ```json [ @@ -29,16 +32,16 @@ Advice: wrap _marks_ in special symbols, i.e. `__uuid__` and unwrap during `oper ## Operations + The library supports a number of operations, named _Mode_: - * `ModeInsert`: insert key/value pair after the _mark_. - * `ModeReplaceValue`: replace or convert value; - * `ModeReplace`: replace entire key/value pair; + * `ModeInsert`: insert key/value pair after the _mark_, + * `ModeReplace`: replace the entire key/value pair, + * `ModeReplaceValue`: replace or convert value and keep key as is, * `ModeDelete`: delete key/value. ## Fragments generators -Type `GenerateFragmentBatchFunc` describes an interface of generators. -Batch processing is a key feature of generators. Batches speed up the result output. +Implement GenerateFragmentBatchFunc interface to create a custom fragment generator. Example: ```go @@ -74,3 +77,5 @@ func Generator(ctx context.Context, iterator jsonj.FragmentIterator, p interface return result, nil } ``` + +Batch processing is a key feature of generators. It speeds up the result output.