DEV Community

loading...

Discussion on: Use Anonymous Structs For JSON Marshalling in Go

Collapse
tmack8080 profile image
tmack8080

Not a programmer.

What about nested structs? Can anonymous structs be used?

For example, I want to mock a JSON response from this API: zabbix.com/documentation/4.2/manua...

Response:

{
    "jsonrpc": "2.0",
    "result": [
        {
            "itemid": "23296",
            "clock": "1351090996",
            "value": "0.0850",
            "ns": "563157632"
        },
        {
            "itemid": "23296",
            "clock": "1351090936",
            "value": "0.1600",
            "ns": "549216402"
        },
    ],
    "id": 1
}

Thanks