提交 8694e415 编写于 作者: K ks 提交者: tanghai

修复反序列化配置数据时,LitJson不支持float类型的错误 (#117)

上级 e9811558
......@@ -714,6 +714,8 @@ namespace LitJson
};
RegisterImporter (base_importers_table, typeof (string),
typeof (DateTime), importer);
RegisterImporter<double, float>(input => Convert.ToSingle(input));
}
private static void RegisterImporter (
......@@ -754,6 +756,11 @@ namespace LitJson
writer.Write ((string) obj);
return;
}
if (obj is Single) {
writer.Write((float)obj);
return;
}
if (obj is Double) {
writer.Write ((double) obj);
......
......@@ -225,7 +225,7 @@ namespace LitJson
writer.Write ('"');
//直接存储原始字符串,不再做任何转义字符的解析
//ֱ�Ӵ洢ԭʼ�ַ������������κ�ת���ַ��Ľ���
writer.Write(str);
writer.Write('"');
return;
......@@ -464,5 +464,16 @@ namespace LitJson
context.ExpectingValue = true;
}
public void Write(float number)
{
DoValidation(Condition.Value);
PutNewline();
string str = number.ToString();
Put(str);
context.ExpectingValue = false;
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册