Skip to content
Node: JSON.parse/stringifygithub.com/sahilkhaire/gox/json

MustParse

Overview

MustParse unmarshals or panics.

Part of the json package — Node.js analog: JSON.parse/stringify.

Signature

go
func MustParse(data []byte, v any)

Compare: Node.js · Standard Go · gox

js
// Typical JSON.parse/stringify pattern in Node.js
go
err := json.Unmarshal([]byte(raw), &v)
go
import "github.com/sahilkhaire/gox/json"

var user User
json.MustParse([]byte(raw), &user)

Example

go
import "github.com/sahilkhaire/gox/json"

var user User
json.MustParse([]byte(raw), &user)

Tips

Import github.com/sahilkhaire/gox/json and call MustParse directly. See the comparison below for the standard library equivalent.

Standard library alternative

Use the standard library directly:

go
err := json.Unmarshal([]byte(raw), &v)

Back to json package overview

MIT Licensed · Built for Node.js developers moving to Go