如何将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 (将#修改为@)