tmc / json-to-struct

A simple command-line tool for generating to struct definitions from JSON
GNU General Public License v3.0
40 stars 7 forks source link

Handling of repeated fields having different subset of fields #7

Open ptabor opened 8 months ago

ptabor commented 8 months ago

Hi,

I required a tool that is able to handle properly big repeated messages in which different subsets of fields are set, without declaring them quickly as interface{}. Inspired by this project, did major cleanup of the logic.

In particular now:

[
   {
       a: 1
    }, 
    {
       a: 6
       b: "abc"
     }, 
     {
        b: ""
        c: 1.3
     }
]

will propose:

   struct {
      A *int
      B string
      C *float64
   }

If that change is improvement to you, please consider merging. Otherwise I will maintain my own variant of the library.