jsonutil

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertUnicodeToASCII

func ConvertUnicodeToASCII(data []byte) []byte

ConvertUnicodeToASCII converts selected unicode characters to an ascii representation to support intended output. For instance, a byte stream may include a unicode representation of the ampersand symbol (`&`) or various formatting characters and in many cases ascii is the desired output with a common example being JSON.

func Flatten

func Flatten(jsonBytes []byte, path, formatter string) []string

Flatten parses JSON data into a flattened string array of key/value pairs formatted with the provided formatter string. The path value determines which part of the object should be plucked for parsing. Flattened keys will consist of uppercase characters only with path elements separated by underscores.

For example: ```json

{
   "environment": {
       "jwt_token": "006da898a814ff27e55900b8",
       "new_relic": {
           "app_name": "test-app",
           "enabled": "false",
           "license_key": "1a2fc8a8eeb33ad0bba6cc5c",
           "log_level": "info"
       },
   }
}

```

Given the path `environment` only its children `jwt_token`, `new_relic`, `app_name`, etc. will be inspected. An array of key/value strings returned will look like the following, if given the formatter `%s="%s"`:

```go [

`JWT_TOKEN="006da898a814ff27e55900b8"`,
`NEW_RELIC_APP_NAME="processor-staging"`,
`NEW_RELIC_ENABLED="false"`,
`NEW_RELIC_LICENSE_KEY=""`,
`NEW_RELIC_LOG_LEVEL="info"`,
`SERVER_BASE_URL="https://institutional-api-staging.alphaflow.com/v1"`,

] ```

Types

This section is empty.

Jump to

Keyboard shortcuts

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