api 的 json 响应是这样的
{
"ResponseCode": "1",
"Response": "Data Found",
"data": [
{
"Season": "KHARIF",
"Sector": "AGRICULTURE",
"Category": "Cereals",
"Crop": "Paddy (Dhan)",
"QueryType": "\tField Preparation\t",
"QueryText": "top dressing for paddy",
"KccAns": "top dressing for paddy : apply urea 25kg+SSP 15kg + neem cake 5kg+MN mixture 5kg mixed with 40kg of sand",
"StateName": "PUDUCHERRY",
"DistrictName": "KARAIKAL",
"BlockName": "KARAIKAL",
"CreatedOn": "1/5/2014 6:48:09 PM"
},
{
"Season": "KHARIF",
"Sector": "AGRICULTURE",
"Category": "Others",
"Crop": "Others",
"QueryType": "Weather",
"QueryText": "weather forecasting details",
"KccAns": "today no rain",
"StateName": "PUDUCHERRY",
"DistrictName": "KARAIKAL",
"BlockName": "KARAIKAL",
"CreatedOn": "1/5/2014 9:04:50 PM"
},
{
"Season": "KHARIF",
"Sector": "AGRICULTURE",
"Category": "Others",
"Crop": "Others",
"QueryType": "0",
"QueryText": "details about soil testing",
"KccAns": "contact to agricultural department",
"StateName": "PUDUCHERRY",
"DistrictName": "KARAIKAL",
"BlockName": "KARAIKAL",
"CreatedOn": "1/8/2014 10:21:18 AM"
},
{
"Season": "KHARIF",
"Sector": "AGRICULTURE",
"Category": "Cereals",
"Crop": "Paddy (Dhan)",
"QueryType": "Fertilizer Use and Availability",
"QueryText": "paddy top dressing fertilizer",
"KccAns": "apply urea 25 kg + potash 15 kg + neem cake 5 kg + microfood 5 kg / ac",
"StateName": "PUDUCHERRY",
"DistrictName": "KARAIKAL",
"BlockName": "KARAIKAL",
"CreatedOn": "1/12/2014 8:01:45 AM"
}
]
}
我正在尝试编写一个 golang 模板,它仅返回响应对象数据部分中的前两个数据点。{{range $element := .data}} {{$element}} {{end}}这是我目前正在使用的模板,但这会返回 .data 字段中的所有子数据。我怎样才能进行这个锻炼。
RISEBY
相关分类