我想檢索字段名稱而不是它們的值。如何檢索json文件中的所有字段?
我當前的代碼是:
app.get("/api/borough_all_fields", function(req, res){
// set the type of content in the response
res.writeHead(200, {'Content-Type': 'application/json'});
var borFld = null;
// what to put in here?
// add the results to an array
respJson["results"] = [ borFld ];
res.end(JSON.stringify(respJson));
});
而且如何指定字段名稱和所有記錄返回它的價值呢?例如,指定GSS_code
並返回所有值,僅用於gss代碼及其名稱?
由於存儲在json中的鍵值對不能獲取鍵的名稱。 – Atula
@Atula任務清楚地說: 「返回:數據集中存在的所有字段名稱(例如,」General_Fertility_Rate-2013「等)。**不返回字段的值,只是字段名稱。** 所以必須有一些方法 – Luffydude
如果你知道的話很好,在這裏發表吧。這會很好。 – Atula