package main import ( "github.com/mailru/easyjson/jwriter" "fmt" ) func main() { w := jwriter.Writer{} w.RawString("Hello, World!") fmt.Println(string(w.Buffer.BuildBytes())) }
package main import ( "github.com/mailru/easyjson/jwriter" "encoding/json" "fmt" ) func main() { w := jwriter.Writer{} w.RawObjectStart() w.RawString("firstname") w.RawString("John") w.RawString("lastname") w.RawString("Doe") w.RawString("age") w.RawInt(30) w.RawObjectEnd() jsonbytes := w.Buffer.BuildBytes() fmt.Println(string(jsonbytes)) }Description: This code example creates a new writer and starts writing a raw JSON object by calling `RawObjectStart()` method. It then writes the key-value pairs for first name, last name, and age as string and integer using `RawString()` and `RawInt()` methods respectively. Finally, the JSON object is completed by calling `RawObjectEnd()`. The JSON output is printed to the console using the `BuildBytes()` and `string()` methods.