go-json icon indicating copy to clipboard operation
go-json copied to clipboard

Custom number format

Open softexpert opened this issue 3 years ago • 1 comments

Hello,

Is there a way to encode a float value as a 2 decimal string ? Even better, can a custom format be specified ? Example: following Go structure

type MyTest struct{
MyValue  float `json:"myvalue",fmt:"# ##0.00"`
}

should give the following json; serialization / de-serialization should be possible :

{
"myvalue": "1 234.00"
}

Thank you for any idea !

softexpert avatar Jan 25 '22 19:01 softexpert

I didn't understand why you needed this feature. Could you specifically explain why you need this feature ?

goccy avatar Jan 27 '22 02:01 goccy