1

I previously asked this question and got berated

NodeJS/C++ addons - Passing an array from node to C++.

However I made it very clear in the question that I want to pass this array from NodeJS to C++ via a C++.

One of the answers was to use JSON, is there any other way to do this?

1
  • What exactly are you trying to accomplish? Why do you need both C++ and Nodejs in the first place? Otherwise, "just write your array to a file" would be a general, correct, and very useless answer, but it's impossible to suggest more without knowing context. Commented Apr 30, 2021 at 18:38

2 Answers 2

0

Please checkout this example

passing array to c++

Sign up to request clarification or add additional context in comments.

Comments

0

If you have the Local<Array> array, you can simply loop thru it and add all the values to a C++ vector using the Length() method that returns the length and the [] operator that returns an element on an index. That is probably the fastest way to do it. Using JSON will result in performance drops.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.