我有一个看起来像JSON的
"results": [
{
"plate": "FRJ7248",
"confidence": 94.583724975586,
"matches_template": 1,
"plate_index": 0,
"region": "us-ny",
"region_confidence": 88,
"processing_time_ms": 94.328330993652,
"requested_topn": 25,
"coordinates": [
{
"x": 1545,
"y": 233
},
{
"x": 1640,
"y": 241
},
...
...
我想知道如何解析coordinates
数组,我尝试了以下操作:
BOOST_FOREACH(boost::property_tree::ptree::value_type& v, pt.get_child("results")) {
ptree subtree1 = v.second.get<string>;
BOOST_FOREACH(boost::property_tree::ptree::value_type& w, subtree1) {
LOG_NS_INFO << "OpenALPR X " << w.second.get<string>("x");
LOG_NS_INFO << "OpenALPR Y " << w.second.get<string>("y");
}
}
但是得到了
error: conversion from ‘<unresolved overloaded function type>’ to non-scalar type ‘boost::property_tree::ptree {aka boost::property_tree::basic_ptree<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >}’ requested
ptree subtree1 = v.second.get<string>;
我该如何解决?
答案 0 :(得分:1)
该消息显示"conversion from ‘<unresolved overloaded function type>’"
,因为您没有打电话 get
。
但是您不应该使用get
,应该执行与"results"
相同的操作:
ptree subtree1 = v.second.get_child("coordinates");