I have a JSON of below structure:
[
{
"option_id": "cust_info",
"value_type": "JSON",
"value": {
"validForVerification": true,
"firstLetter": "S",
"lastLetter": "I"
}
},
{
"option_id": "settings_show_image",
"value_type": "Boolean",
"value": 1
},
{
"option_id": "bonus_disabled_notified",
"value_type": "Boolean",
"value": false
},
{
"option_id": "free_mugs_limit",
"value_type": "Integer",
"value": -1
},
{
"option_id": "leaderboard_notification",
"value_type": "Integer",
"value": 17000000
},
{
"option_id": "parental_control",
"value_type": "Integer",
"value": 1
},
{
"option_id": "rewards_cap",
"value_type": "Integer",
"value": 40
},
{
"option_id": "voluntary_death",
"value_type": "Integer",
"value": 0
},
{
"option_id": "golden_triangle",
"value_type": "Boolean",
"value": false
},
{
"option_id": "location_based_service_enable",
"value_type": "Boolean",
"value": true
}
]
The value
filed changes type depending on the value_type
-- I tried doing this using interface{} in struct, but the problem is when I try to get an int type or when value is an object how to access internal fields like validForVerification
etc.. I also tried parsing into map, but it fails.
I have no control on the API - so I have to live with this weird JSON.