all repos

json2go @ 7dcc81f

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
Authored at: 2025-11-27 14:53:01 +0200
Change ID: wolttrzktuzrxoxwnpskzkswoulrnmrk
Parent: 998d829
M json2go.go
···
        24
        24
         	return &Transformer{}

      
        25
        25
         }

      
        26
        26
         

      
        27
        
        -// Transform ...

      
        28
        
        -// todo: take io.Reader as input?

      
        29
        
        -// todo: output as io.Writer?

      
        
        27
        +// Transform transforms provided json string into go type annotation

      
        30
        28
         func (t *Transformer) Transform(structName, jsonStr string) (string, error) {

      
        31
        29
         	if !identRe.MatchString(structName) {

      
        32
        30
         		return "", ErrInvalidStructName

      ···
        89
        87
         		fieldType := t.getGoType(fieldName, f.type_)

      
        90
        88
         		t.currentIndent--

      
        91
        89
         

      
        92
        
        -		// todo: toggle json tags generation

      
        93
        90
         		jsonTag := fmt.Sprintf("`json:\"%s\"`", f.field)

      
        94
        91
         

      
        95
        92
         		indent := strings.Repeat("\t", t.currentIndent+1)