go-json-postscript

command module
v0.0.0-...-5681ded Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 5 Imported by: 0

README

GO JSON POSTSCRIPT

Provide a list of postscripts for your JSON. You can also add / modify according to your needs.

Prerequisite

Go 1.21.7 or newer. You may be able to use different versions, but please watch out for compatibility.

How to use

  1. Determine your postscripts in postscripts/init.go
  2. If you need a different custom, you may create a new one under postscripts/ then do step (1). It's possible to execute multiple postscripts.
  3. Run the service with make run
  4. Provide the input in files/input.json
  5. See the output in files/output.json. The output is automatically generated every time you save your input in files/input.json

Example

convertJSONStrings

Input

{   
    "ori": {
        "id": 1,
        "word": "a",
        "code": false,
        "score": 0.1
    },
    "json_string": "{\"id\":2,\"word\":\"b\",\"code\":true,\"score\":0.2}",
    "json_strings": [
        {"json_string": "{\"id\":3,\"word\":\"c\",\"code\":false,\"score\":0.3}"},
        {"json_string": "{\"id\":4,\"word\":\"d\",\"code\":true,\"score\":0.4}"}
    ]
}

Output

{
    "json_string": {
        "code": true,
        "id": 2,
        "score": 0.2,
        "word": "b"
    },
    "json_strings": [
        {
            "json_string": {
                "code": false,
                "id": 3,
                "score": 0.3,
                "word": "c"
            }
        },
        {
            "json_string": {
                "code": true,
                "id": 4,
                "score": 0.4,
                "word": "d"
            }
        }
    ],
    "ori": {
        "code": false,
        "id": 1,
        "score": 0.1,
        "word": "a"
    }
}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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