[英]Iterate Napi::Object Properties (Keys) in Node.js C++ N-API
I am having a problem using c++ n-api api and I have reviewed the documentation here , and I do not see a way to iterate the keys of a Napi::Object
. 我在使用c ++ n-api api时遇到问题,并且在这里查看了文档,但没有看到迭代
Napi::Object
的键的方法。 I must be missing something because this is possible in JavaScript, so it must be possible in the C++ API. 我必须缺少一些东西,因为这在JavaScript中是可能的,因此在C ++ API中也必须是可能的。
How can I list or iterate the keys (properties) in a Napi::Object. 如何列出或迭代Napi :: Object中的键(属性)。
It seems the Doxygen documentation which Google surfaced at https://nodejs.github.io/node-addon-api/
is out-of-date. Google似乎在
https://nodejs.github.io/node-addon-api/
上出现的Doxygen文档似乎已过时。
The right place to look is on the Node.js Github repo at https://github.com/nodejs/node-addon-api/blob/master/napi.h 正确的位置在https://github.com/nodejs/node-addon-api/blob/master/napi.h上的Node.js Github存储库上
Looking at the correct header version, Napi::Object
has a function GetPropertyNames()
which is exactly what I needed (though it is oddly not const
). 查看正确的标头版本,
Napi::Object
具有函数GetPropertyNames()
正是我所需要的(尽管很奇怪,它不是const
)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.