我想检索字段名称而不是它们的值。如何检索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