Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/soh335/jsongostruct

generate golang struct from json by go/ast
https://github.com/soh335/jsongostruct

Last synced: 14 days ago
JSON representation

generate golang struct from json by go/ast

Awesome Lists containing this project

README

        

# jsongostruct

generate golang struct from json by go/ast

## example

```
cat /path/to/jsonfile | jsongostruct
```

```json
{
"url": "http://example.com",
"id": 12345,
"name": "web",
"bool": true,
"array": [
"foo",
"bar"
],
"map": {
"foo": "bar",
"dameleon": "dame"
}
}
```

```go
type XXX struct {
Url string `json:"url"`
Id float64 `json:"id"`
Name string `json:"name"`
Bool bool `json:"bool"`
Array []string `json:"array"`
Map struct {
Foo string `json:"foo"`
Dameleon string `json:"dameleon"`
} `json:"map"`
}
```

## TODO

* testing
* tag position for struct type
* nil value handling ( current, null value's type is interface{} )
* detect array type more smart. ( current, detect type from first element of array )