all repos

json2go @ 7dcc81f533a5e18fb6a2900821215b32b7084ab4

convert json to go type annotations
1 files changed, 1 insertions(+), 4 deletions(-)
some polishing
Author: Oleksandr Smirnov olexsmir@gmail.com
Committed at: 2025-11-27 14:55:52 +0200
Change ID: wolttrzktuzrxoxwnpskzkswoulrnmrk
Parent: 998d829
M json2go.go

@@ -24,9 +24,7 @@ func NewTransformer() *Transformer {

return &Transformer{} } -// Transform ... -// todo: take io.Reader as input? -// todo: output as io.Writer? +// Transform transforms provided json string into go type annotation func (t *Transformer) Transform(structName, jsonStr string) (string, error) { if !identRe.MatchString(structName) { return "", ErrInvalidStructName

@@ -89,7 +87,6 @@ t.currentIndent++

fieldType := t.getGoType(fieldName, f.type_) t.currentIndent-- - // todo: toggle json tags generation jsonTag := fmt.Sprintf("`json:\"%s\"`", f.field) indent := strings.Repeat("\t", t.currentIndent+1)