我正在尝试打开一个文件而.json已经将它发送给了一个类。 但是我做错了。
ref class CutAnnotationJSon { public: int index; String^ nomeTipo; double pontoX1; double pontoY1; double pontoX2; double pontoY2; double height; int r; int g; int b; int numberCut; }; ref class PanoramicAnnotationJSon { public: int index; String^ nomeTipo; double pontoX1; double pontoY1; double pontoX2; double pontoY2; int r; int g; int b; }; ref class DadosJSon { public: List<PanoramicAnnotationJSon^>^ panoramicAnnotation = gcnew List<PanoramicAnnotationJSon^>; List<CutAnnotationJSon^>^ cutAnnotation = gcnew List<CutAnnotationJSon^>; };运用
DadosJSon^ dadosJSon = JsonConvert::DeserializeObject<DadosJSon^>(File::ReadAllText("c:/movie.json"));错误信息:
103 IntelliSense: more than one instance of overloaded function "Newtonsoft::Json::JsonConvert::DeserializeObject" matches the argument list: function template "T Newtonsoft::Json::JsonConvert::DeserializeObject<T>(System::String ^value)" function template "T Newtonsoft::Json::JsonConvert::DeserializeObject<T>(System::String ^value, ... cli::array<Newtonsoft::Json::JsonConverter ^, 1> ^converters)" argument types are: (System::String ^)
我正在使用Newtonsoft::Json::;
I'm trying to open a file and .json already sends it to a Class. But I get error when doing.
ref class CutAnnotationJSon { public: int index; String^ nomeTipo; double pontoX1; double pontoY1; double pontoX2; double pontoY2; double height; int r; int g; int b; int numberCut; }; ref class PanoramicAnnotationJSon { public: int index; String^ nomeTipo; double pontoX1; double pontoY1; double pontoX2; double pontoY2; int r; int g; int b; }; ref class DadosJSon { public: List<PanoramicAnnotationJSon^>^ panoramicAnnotation = gcnew List<PanoramicAnnotationJSon^>; List<CutAnnotationJSon^>^ cutAnnotation = gcnew List<CutAnnotationJSon^>; };using
DadosJSon^ dadosJSon = JsonConvert::DeserializeObject<DadosJSon^>(File::ReadAllText("c:/movie.json"));Error Message:
103 IntelliSense: more than one instance of overloaded function "Newtonsoft::Json::JsonConvert::DeserializeObject" matches the argument list: function template "T Newtonsoft::Json::JsonConvert::DeserializeObject<T>(System::String ^value)" function template "T Newtonsoft::Json::JsonConvert::DeserializeObject<T>(System::String ^value, ... cli::array<Newtonsoft::Json::JsonConverter ^, 1> ^converters)" argument types are: (System::String ^)
I'm using Newtonsoft::Json::;
最满意答案
我无法重现这个问题。 但是,您可以通过以下方式显式选择JsonConvert.DeserializeObject(String, JsonSerializerSettings)重载(它可以执行您想要的操作):
DadosJSon^ dadosJSon = JsonConvert::DeserializeObject<DadosJSon^>(File::ReadAllText("c:/movie.json"), (JsonSerializerSettings ^)nullptr);传递设置的nullptr值等同于JsonConvert::DeserializeObject<DadosJSon^>(File::ReadAllText("c:/movie.json")) 。
I cannot reproduce the problem. However, you could explicitly select the JsonConvert.DeserializeObject(String, JsonSerializerSettings) overload (which does what you want) via:
DadosJSon^ dadosJSon = JsonConvert::DeserializeObject<DadosJSon^>(File::ReadAllText("c:/movie.json"), (JsonSerializerSettings ^)nullptr);Passing a nullptr value for the settings is equivalent to JsonConvert::DeserializeObject<DadosJSon^>(File::ReadAllText("c:/movie.json")).
更多推荐
发布评论