Popularity
1.1
Growing
Activity
0.0
Stable
7
2
2
Programming language: Go
License: MIT License
Tags:
Json
Latest version: v1.1.1
ej alternatives and similar packages
Based on the "JSON" category.
Alternatively, view ej alternatives based on common mentions on social networks and blogs.
-
jsonparser
One of the fastest alternative JSON parser for Go that does not require schema -
fastjson
Fast JSON parser and validator for Go. No custom structs, no code generation, no reflection -
jsondiff
Compute the diff between two JSON documents as a series of RFC6902 (JSON Patch) operations -
JSON-to-Proto
convert JSON to Protocol Buffers online in your browser instantly -
ujson
µjson - A fast and minimal JSON parser and transformer that works on unstructured JSON -
mapslice-json
Go MapSlice for ordered marshal/ unmarshal of maps in JSON -
go-jsonerror
Small package which wraps error responses to follow jsonapi.org -
epoch
Contains primitives for marshaling/unmarshaling Unix timestamp/epoch to/from built-in time.Time type in JSON -
go-parameters
:blue_book: Easily parse incoming parameters and values from an HTTP request
Developer Ecosystem Survey 2022
Take part in the Developer Ecosystem Survey 2022 by JetBrains and get a chance to win a Macbook, a Nvidia graphics card, or other prizes. We’ll create an infographic full of stats, and you’ll get personalized results so you can compare yourself with other developers.
Promo
surveys.jetbrains.com
Do you think we are missing an alternative of ej or a related project?
Popular Comparisons
README
Easy Json (EJ)
Package ej
implements a JSON handler to write and read json succinctly from different sources like files and http requests.
Install
go get -u github.com/lucassscaravelli/ej
Examples
File
package main
type exData struct {
Hello int
World []string
}
func main() {
dataWrite := &exData{
Hello: 1,
World: []string{"h", "e", "l", "l", "o"},
}
var dataRead exData
// marshal the content of "dataWrite" to JSON and write in "ex.json" file
if err := ej.JSON(from.File("ex.json")).Write(&dataWrite); err != nil {
log.Fatal(err)
}
// read the data of "ex.json" file and unmarshal the JSON to "dataRead" content
if err := ej.JSON(from.File("ex.json")).ParseToData(&dataRead); err != nil {
log.Fatal(err)
}
// equal content
fmt.Printf("dataWrite: %+v\n", dataWrite)
fmt.Printf("dataRead: %+v\n", dataRead)
}
HTTP Request
package main
import (
"log"
"net/http"
"github.com/lucassscaravelil/ej"
"github.com/lucassscaravelil/ej/from"
)
type requestPayload struct {
NumberToFind int
Numbers []int
}
type responseErrorPayload struct {
StatusCode int
ErrorTxt string
}
type responsePayload struct {
Found bool
Number int
}
func writeError(jsonHandler *ej.EJ, status int, err error) {
jsonHandler.Write(&responseErrorPayload{
StatusCode: status,
ErrorTxt: err.Error(),
})
}
func main() {
http.HandleFunc("/bar", func(w http.ResponseWriter, r *http.Request) {
var bodyData requestPayload
jsonHandler := ej.JSON(from.Request(w, r))
if err := jsonHandler.ParseToData(&bodyData); err != nil {
writeError(jsonHandler, http.StatusBadRequest, err)
return
}
found := false
foundNumber := 0
for _, number := range bodyData.Numbers {
if number == bodyData.NumberToFind {
found = true
foundNumber = number
break
}
}
jsonHandler.Write(&responsePayload{
Found: found,
Number: foundNumber,
})
return
})
log.Fatal(http.ListenAndServe(":8080", nil))
}
HTTP Response
package main
import (
"log"
"net/http"
"github.com/lucassscaravelil/ej"
"github.com/lucassscaravelil/ej/from"
)
type testData struct {
Count int
Txt string
}
func main() {
var responseData testData
response, err := http.Get("http://<url>/any")
if err != nil {
log.Fatal(err)
}
if err := ej.JSON(Response(response)).ParseToData(&responseData); err != nil {
log.Fatal(err)
}
fmt.Printf("dataRead: %+v\n", responseData)
}