Breyta is a json-xls REST client. Breyta retries if json-xls server isn't responding with exponential jitter backoff strategy.
Breyta expects a Mashape account and the json-xls API key. You can obtain a key from here after subscribing to one of the plans.
Using go get
go get -u -v github.com/younisshah/breyta
Using govendor
govendor fetch -v github.com/younisshah/breyta
To convert a JSON string to XLSX/XLS
b := breyta.NewJSONClient(breyta.FormatXlsx, breyta.Both, breyta.LayoutAuto, breyta.Both, "MASHAPE_KEY")
convertedBytes, err := b.ConvertJSON(`[{"Name":"root1","children":[{"Name":"AAA","Age":"22","Job":"PPP"},{"Name":"BBB","Age":"25","Job":"QQQ"}]},{"Name":"root2","children":[{"Name":"CCC","Age":"38","Job":"RRR"}]},{"Name":"root3","children":[]}]`)
if err != nil {
//
}
// Do something to convertedBytes. Maybe save to a file
To convert an XML string to XLSX/XLS
b := breyta.NewXMLClient(breyta.FormatXlsx, breyta.Both, breyta.LayoutAuto, breyta.Both, "MASHAPE_KEY")
convertedBytes, err := b.ConvertXML(`<?xml version=\"1.0\" encoding=\"UTF-8\"?><note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Do not forget me this weekend!</body></note>`)
if err != nil {
//
}
// Do something to convertedBytes. Maybe save to a file
- Add support for
ConvertJsonFile
API - Add support for
ConvertXmlFile
API.
MIT