jsoncase

package module
v0.0.0-...-2e012b5 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2020 License: MIT Imports: 3 Imported by: 0

README

jsoncase

a go package for converting json case to various cases

Godoc Reference PkgGoDev Coverage Go Report Card

Example

s := `
{
  "a_b": {
    "c_d": "e"
  },
  "b_e": "x",
  "e_f": [
    {
      "c_f": "e"
    }
  ],
  "x_y": {
    "a_b": {
      "c_d": "e"
    },
    "b_e": "x",
    "e_f": [
      {
        "c_f": "e"
      }
    ]
  }
}
`
s2 := ToCamelJson(s)
fmt.Prilntln(s2)
=> `
{
  "aB": {
    "cD": "e"
  },
  "bE": "x",
  "eF": [
    {
      "cF": "e"
    }
  ],
  "xY": {
    "aB": {
      "cD": "e"
    },
    "bE": "x",
    "eF": [
      {
        "cF": "e"
      }
    ]
  }
}
`
Function Usage
ToSnakeJson string-string
ToCamelJson string-string
ToSnakeJsonBytes []byte-[]byte
ToCamelJsonBytes []byte-[]byte
ToSnakeVal interface{} - interface{}
ToCamelVal interface{} - interface{}

Install

go get -u https://github.com/vchitai/jsoncase

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToCamelJSON

func ToCamelJSON(json string) string

ToCamelJSON convert the fieldName of object in json string to camelCase

func ToCamelJSONBytes

func ToCamelJSONBytes(json []byte) []byte

ToCamelJSONBytes convert the fieldName of object in json bytes to camelCase

func ToCamelVal

func ToCamelVal(json interface{}) interface{}

ToCamelVal transform all fieldName of map[string]interface embedded in the interface{} to camelCase

func ToPascalJSON

func ToPascalJSON(json string) string

ToPascalJSON convert the fieldName of object in json string to PascalCase

func ToPascalJSONBytes

func ToPascalJSONBytes(json []byte) []byte

ToPascalJSONBytes convert the fieldName of object in json bytes to PascalCase

func ToPascalVal

func ToPascalVal(json interface{}) interface{}

ToPascalVal transform all fieldName of map[string]interface embedded in the interface{} to PascalCase

func ToSnakeJSON

func ToSnakeJSON(json string) string

ToSnakeJSON convert the fieldName of object in json string to snake_case

func ToSnakeJSONBytes

func ToSnakeJSONBytes(json []byte) []byte

ToSnakeJSONBytes convert the fieldName of object in json bytes to snake_case

func ToSnakeVal

func ToSnakeVal(json interface{}) interface{}

ToSnakeVal transform all fieldName of map[string]interface embedded in the interface{} to snake_case

func TransformJSON

func TransformJSON(transformation func(string) string) func(string) string

TransformJSON transform the fieldName of object in json string using transformation function

func TransformJSONBytes

func TransformJSONBytes(transformation func(string) string) func([]byte) []byte

TransformJSONBytes transform the fieldName of object in json bytes using transformation function

func TransformMap

func TransformMap(transformation func(string) string) func(json map[string]interface{}) map[string]interface{}

TransformMap transform fieldName of all map[string]interface embedded in the root map using the transformation function.

func TransformVal

func TransformVal(transformation func(string) string) func(json interface{}) interface{}

TransformVal transform all fieldName of map[string]interface embedded in the interface{} using the transformation function

Types

This section is empty.

Jump to

Keyboard shortcuts

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