JsonConvert :: DeserializeObject erro c ++ cli(JsonConvert::DeserializeObject erro c++ cli)

编程入门 行业动态 更新时间:2024-10-19 14:34:09
JsonConvert :: DeserializeObject erro c ++ cli(JsonConvert::DeserializeObject erro c++ cli)

我正在尝试打开一个文件而.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")).

更多推荐

本文发布于:2023-08-05 06:59:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1428896.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:DeserializeObject   JsonConvert   cli   erro

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!