thedevsaddam / gojsonq

A simple Go package to Query over JSON/YAML/XML/CSV Data
https://github.com/thedevsaddam/gojsonq/wiki
MIT License
2.18k stars 140 forks source link

How to map result to struct? #25

Closed vojbarzz closed 5 years ago

vojbarzz commented 5 years ago

Hello, having following query applications.WhereEqual("reporting", false).Select("applications").Only("id", "name") and need to map it to struct.

Example of return value is [map[id:1.94664978e+08] map[id:1.12640692e+08] map[id:1.94411185e+08]]

Could You suggest how? Having no idea :(

thedevsaddam commented 5 years ago

You can iterate over the []interface{} and populate your struct (this is good but you need to assert the value yourself)

Or you can encode to json and write the byte to the struct by decoding json