我对GSON很难过.
我有一个简单的JSON,我想反序列化为Map<String,Object>.
我真的很直观,123应该被解析为int(或long),123.4应该被解析为float(或double).
另一方面,GSON一直创造双打.
我可以告诉GSON不要一直滥用双倍?
我的实际代码:
Type mapType = new TypeToken<Map<String, Object>>() {}.getType();
GSON gson = new Gson();
Map<String, Object> map = gson.fromJson(someString, mapType);
Run Code Online (Sandbox Code Playgroud) 阅读本教程:http://ddili.org/ders/d.en/function_parameters.html
我不明白之间的差别in和const:是什么呢?
dchar lastLetter(const dchar[] str) {
return str[$ - 1];
}
dchar lastLetter(in dchar[] str) {
return str[$ - 1];
}
Run Code Online (Sandbox Code Playgroud) 在DI中可以指定const函数,就像在c ++中一样:
struct Person {
string name;
// these two are the same?
const string getConstName() { return name; }
string getConstName2() const { return name; }
}
Run Code Online (Sandbox Code Playgroud)
看来上面两个是相同的含义.这是真的吗?
如果是这样,我怎么能返回一个const字符串而不是定义一个const函数?