如何解决如何将V8元素转换为C ++类型?
在我的程序中,我需要从JSON获取数据,但是为此,我需要传递给我的插件的数组中的字符串值。我将如何将数组中的V8元素更改为可用于从JSON访问数据的字符串? 到目前为止,这是我想出的:
void water(const FunctionCallbackInfo<Value> &args)
{
Json::Value waterjson;
std::ifstream people_file("waterjson.json",std::ifstream::binary);
people_file >> waterjson;
Local<Array> a;
Local<Array> b;
if(args[0]->IsArray())
{
a = args[0].As<Array>();
b = args[1].As<Array>();
}
int total=0;
for(int i=0; i<a->Length(); i++)
{
int c = waterjson[a->Get(i)]["content"];
int s = waterjson[a->Get(i)]["serving"];
int m = s/100;
int amount = c*m;
total+=(amount*b->Get(i)->NumberValue());
}
args.GetReturnValue().Set(total);
}
我的错误是:
no operator "[]" matches these operands -- operand types are: Json::Value [ v8::Local<v8::Value> ]
no operator "*" matches these operands -- operand types are: int * v8::Maybe<double>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。