Popularity
0.9
Growing
Activity
0.0
Stable
6
2
2
Programming language: Go
License: MIT License
Tags:
Json
omg.jsonparser alternatives and similar packages
Based on the "JSON" category.
Alternatively, view omg.jsonparser alternatives based on common mentions on social networks and blogs.
-
fastjson
Fast JSON parser and validator for Go. No custom structs, no code generation, no reflection -
trdsql
CLI tool that can execute SQL queries on CSV, LTSV, JSON, YAML and TBLN. Can output to various formats. -
marshmallow
Marshmallow provides a flexible and performant JSON unmarshalling in Go. It specializes in dealing with unstructured struct - when some fields are known and some aren't, with zero performance overhead nor extra coding needed. -
epoch
Contains primitives for marshaling/unmarshaling Unix timestamp/epoch to/from built-in time.Time type in JSON -
jsonhandlers
JSON library to expose simple handlers that lets you easily read and write json from various sources. -
JSON Data Manager
JSON Data Manager is a Go library designed to efficiently manage and filter JSON data from files
CodeRabbit: AI Code Reviews for Developers
Revolutionize your code reviews with AI. CodeRabbit offers PR summaries, code walkthroughs, 1-click suggestions, and AST-based analysis. Boost productivity and code quality across all major languages with each PR.
Promo
coderabbit.ai
Do you think we are missing an alternative of omg.jsonparser or a related project?
README
omg.jsonParser
omg.jsonParser is a simple JSON parser with a simple condition validation. It's a wrapper on standard go JSON lib. With it help you can add the validation condition via golang structure fields tags.
Example
package main
import (
"fmt"
"github.com/dedalqq/omg.jsonparser"
)
func main() {
jsonData := `{"name": ""}`
st := struct {
Name string `json:"name,notEmpty"` // added notEmpty for enable validation for it field
}{}
err := jsonparser.Unmarshal([]byte(jsonData), &st)
if err != nil {
fmt.Println(err.Error()) // print: value [name] must be not empty
}
}
Tag struct
json:"[name][,option]..."
Tag examples
Here are some the tag examples:
package main
type data struct {
F1 string `json:"f1,notEmpty"` // the field must be not empty but can be "null" or may not exist
F2 string `json:"f2,notEmpty,required"` // the field is required and must be not empty but may be the "null" value
F3 string `json:"f3,notEmpty,notNull"` // the field must be not empty and not "null" but may not exist
F4 []string `json:"f4,notNull,min:3"` // the field must be not "null" and contains 3 or more items but may not exist
}
Available tags options
Name | Types | Description |
---|---|---|
required |
any | The field must be exist with any value or null |
notEmpty |
any | The field can be not exist but if exist value must be not zero value but can be null |
notEmpty |
slice | The field must have one element or more but may be null or not exist |
notNull |
any | The field should not be null, but may not exist |
uniq |
[]string | The strings slice must contains only unique strings |
min:n |
slice | The slice must have n items or more |
max:n |
slice | The slice must have n items or less |
min:n |
string | The string must have n runes or more |
max:n |
string | The string must have n runes or less |
min:n |
int/uint | The value must be equals n or more |
max:n |
int/uint | The value must be equals n or less |