I am trying to unmarshal this API response to a Golang struct.
{
"0": {
"article_id": 1,
"article_inwebshop": 0,
"article_number": 1111111,
"article_season": 0,
"sizeruler": -3,
"article_freefield2": null,
"article_manufacturer": null,
"article_artfabr": null,
"article_freefield1": "name here",
"article_color": null,
"article_subgroup": "name here",
"article_group": "name here",
"article_price_web": "",
"article_additional_info": "",
"article_description": "name here",
"article_creation_date": "2016-09-30",
"article_basepurprice": "0.00",
"article_baseprice": "0.00",
"article_outlet": 0,
"article_discount": "",
"article_memo": "name here",
"article_supplier": null,
"article_price_web_discount": "",
"article_homepage": 0,
"article_weight": "1.60",
"article_run_out": 0,
"article_metakeywords": "name here",
"article_metadescription": "name here",
"article_metatitle": "name here",
"article_price_wholesale": "0.00",
"article_subsubgroup": "name here",
"salesunit": 1,
"article_deposit": "0.00",
"deliverytime": null,
"article_taxrate": "21.00",
"article_group_extra": [],
"article_is_composed": "false",
"fields": {
"aantal_flessen": "",
"alcoholpercentage": "40%",
"beschikbaarheid": "",
"bottelaar": "name here",
"distillery_merk": "name here",
"druivensoort": "",
"gebotteld": "",
"gedistilleerd": "",
"inhoudsmaat": "1 liter",
"land": "",
"leeftijd": "no-age-statement",
"oogstjaar": "",
"regio": "name here",
"serie": "",
"vatnummer": "",
"vattype": "name here",
"verpakking": "",
"wijnhuis_merk": "",
"article_memo_en": "",
"datum_nieuw_binnen": "",
"doos_prijs": "",
"add_informatie": "",
"test": "",
"maximum_aantal_per_klant": ""
},
"virtual_articles": [],
"virtual_article_parents": [],
"images": [
{
"image_description": "Shan_Classic",
"image_file": "Shan_Classic.jpg",
"image_order": 1,
"image_link": "Shan_Classic.jpg",
"image_checksum": "234234234"
},
{
"image_description": "Anto_Classic",
"image_file": "Anto_Classic.jpg",
"image_order": 2,
"image_link": "Anto_Classic.jpg",
"image_checksum": "234234234"
}
],
"sizes": [
{
"position": 1,
"description": null,
"stock": 0,
"salepricedelta": "0.00",
"purpricedelta": "0.00"
}
],
"barcodes": [
{
"position": 1,
"barcode": "123123123"
},
{
"position": 1,
"barcode": "123123123"
}
],
"article_crossell": [],
"article_upsell": [],
"article_composed": [],
"article_actions": []
},
}
I tried various things, but I am unable to get it working. My latest code is:
var items []map[string]types.Synchronize
err = json.Unmarshal(body, &items)
if err != nil {
fmt.Println(err)
return
}
But that results in an “json: cannot unmarshal object into Go value of type []map[string]types.Synchronize” error.
Can anyone explain to me what I am doing wrong?