Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

golang json omitempty struct

import (
    "fmt"
    "github.com/clarketm/json" // drop-in replacement for `encoding/json`
)

type Result struct {
    Data   MyStruct `json:"data,omitempty"`
    Status string   `json:"status,omitempty"`
    Reason string   `json:"reason,omitempty"`
}

j, _ := json.Marshal(&Result{
    Status: "204",
    Reason: "No Content",
})

fmt.Println(string(j))
Comment

PREVIOUS NEXT
Code Example
Javascript :: JavaScript for loop Display Sum of n Natural Numbers 
Javascript :: js get integer value of 
Javascript :: js UTC to local timezone 
Javascript :: js copy array 
Javascript :: jquery sum table column td 
Javascript :: node.js function 
Javascript :: window scroll top 
Javascript :: usecontext react 
Javascript :: vue 3 create component 
Javascript :: farewell discord.js 
Javascript :: javascript calculate average of array 
Javascript :: javascript empty function 
Javascript :: calling angular component method in service 
Javascript :: react tabs 
Javascript :: mongoose show all indexes 
Javascript :: javascript mod 
Javascript :: array includes 
Javascript :: flatten nested array javascript 
Javascript :: capture keystrokes in javascript 
Javascript :: json comments 
Javascript :: ejs current year 
Javascript :: client.on ready 
Javascript :: async function javascript 
Javascript :: how to access key value pair in javascript 
Javascript :: how do i set an id for a div in js 
Javascript :: get all matches regex javascript 
Javascript :: concat class name vue js 
Javascript :: date format date and time in js 
Javascript :: looping through local storage javascript 
Javascript :: disable long press on chrome 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =