官术网_书友最值得收藏!

JSON output

Now let's say that we have the Citi Bike station data in our stationData struct value and we want to save that data out to a file. We can do this with json.marshal:

// Marshal the data.
outputData, err := json.Marshal(sd)
if err != nil {
log.Fatal(err)
}

// Save the marshalled data to a file.
if err := ioutil.WriteFile("citibike.json", outputData, 0644); err != nil {
log.Fatal(err)
}
主站蜘蛛池模板: 海阳市| 佛山市| 铜陵市| 鸡西市| 东山县| 罗山县| 玉林市| 资阳市| 彭水| 洛川县| 洛南县| 南澳县| 周宁县| 嘉鱼县| 象州县| 简阳市| 简阳市| 万源市| 洪湖市| 海城市| 康马县| 安仁县| 乌兰察布市| 祁东县| 石狮市| 沙河市| 稻城县| 扬州市| 融水| 荣成市| 左权县| 乐至县| 清苑县| 济南市| 贺兰县| 扎鲁特旗| 西林县| 延长县| 库车县| 朝阳市| 宜阳县|