github.com/ecoshub/jin (go): Package jin  Copyright (c) 2020 eco.  License that can be found in the LICENSE file.  "your wish is my command"  Jin is a comprehensive JSON manipulation tool bundle. All functions tested with random data with help of Node.js. All test-path and test-value creation automated with Node.js.  Jin provides parse, interpret, build and format tools for JSON. Third-party packages only used for the benchmark. No dependency need for core functions.  We make some benchmark with other packages like Jin.  In Result, Jin is the fastest (op/ns) and more memory friendly then others (B/op).  For more information please take a look at BENCHMARK section below.  WHAT IS NEW?  7 new functions tested and added to package.  - GetMap() get objects as map[string]string structure with key values pairs  - GetAll() get only specific keys values  - GetAllMap() get only specific keys with map[string]stringstructure  - GetKeys() get objects keys as string array  - GetValues() get objects values as string array  - GetKeysValues() get objects keys and values with separate string arrays  - Length() get length of JSON array.  06.04.2020  INSTALLATION  And you are good to go. Import and start using.  Major difference between parsing and interpreting is parser has to read all data before answer your needs. On the other hand interpreter reads up to find the data you need.  With parser, once the parse is complete you can access any data with no time. But there is a time cost to parse all data and this cost can increase as data content grows.  If you need to access all keys of a JSON then, we are simply recommend you to use Parser. But if you need to access some keys of a JSON then we strongly recommend you to use Interpreter, it will be much faster and much more memory-friendly than parser.  Interpreter is core element of this package, no need to create an Interpreter type, just call which function you want.  First let's look at general function parameters.  We are gonna use Get() function to access the value of path has pointed. In this case 'jin'.  Path value can consist hard coded values.  Get() function return type is []byte but all other variations of return types are implemented with different functions.  For example. If you need "value" as string use GetString().  Parser is another alternative for JSON manipulation.  We recommend to use this structure when you need to access all or most of the keys in the JSON.  Parser constructor need only one parameter.  We can parse it with Parse() function.  Let's look at Parser.Get()  About path value look above.  There is all return type variations of Parser.Get() function like Interpreter.  For return string use Parser.GetString() like this,  Other usefull functions of Jin.  -Add(), AddKeyValue(), Set(), SetKey() Delete(), Insert(), IterateArray(), IterateKeyValue() Tree().  Let's look at IterateArray() function.  There are two formatting functions. Flatten() and Indent().  Indent() is adds indentation to JSON for nicer visualization and Flatten() removes this indentation.  Control functions are simple and easy way to check value types of any path.  For example. IsArray().  Or you can use GetType().  There are lots of JSON build functions in this package and all of them has its own examples.  We just want to mention a couple of them.  Scheme is simple and powerful tool for create JSON schemes.  Testing is very important thing for this type of packages and it shows how reliable it is.  For that reasons we use Node.js for unit testing.  Lets look at folder arrangement and working principle.  - test/ folder:  test-json.json, this is a temporary file for testing. all other test-cases copying here with this name so they can process by test-case-creator.js.  test-case-creator.js is core path & value creation mechanism.	When it executed with executeNode() function. It reads the test-json.json file and generates the paths and values from this files content. With command line arguments it can generate different paths and values. As a result, two files are created with this process. the first of these files is test-json-paths.json and the second is test-json-values.json  test-json-paths.json has all the path values.  test-json-values.json has all the values that corresponding to path values.  - tests/ folder  All files in this folder is a test-case. But it doesn't mean that you can't change anything, on the contrary, all test-cases are creating automatically based on this folder content. You can add or remove any .json file that you want.  All GO side test-case automation functions are in core_test.go file.  This package developed with Node.js v13.7.0. please make sure that your machine has a valid version of Node.js before testing.  All functions and methods are tested with complicated randomly genereted .json files.  Like this,  Most of JSON packages not even run properly with this kind of JSON streams. We did't see such packages as competitors to ourselves. And that's because we didn't even bother to benchmark against them.  Benchmark results.  - Benchmark prefix removed from function names for make room to results. - Benchmark between 'buger/jsonparser' and 'ecoshub/jin' use the same payload (JSON test-cases) that 'buger/jsonparser' package use for benchmark it self.  We are currently working on,  - Marshal() and Unmarshal() functions.  - http.Request parser/interpreter  - Builder functions for http.ResponseWriter  If you want to contribute this work feel free to fork it.  We want to fill this section with contributors.
Keywords: go-json|golang|gotools|interpreter|json|json-go|json-interpreter|json-parser|parser