Dan The Man
Dan The Man

Reputation: 1895

serialize and unserialize array to file - Node JS

I have an array that say for the example looks like that:

var position = [1,3,4,6];

I want to serialize the array to a file, let say position.txt.

Than I want to load the data saved to another running JS program, something like this:

var position = loadArrayFromFile("position.txt");

Is there something that I can use to do that?

Upvotes: 2

Views: 2969

Answers (1)

T.J. Crowder
T.J. Crowder

Reputation: 1074595

JSON and file I/O is how I'd do it:

Upvotes: 5

Related Questions