On Jun 10, 2015, at 11:10 PM, Martin Fares wrote:
>
> Hey guys, I'm creating a page in HTML(duh) but I'm kinda stuck, I need to create a list and save it/transform it into a Json so I can export it.
>
> I randomly read node.js was good for this, I was wondering if a good soul with node knowledge can confirm if this is true or if there exist a easy way to do it or/and a library that might help me here?
Node is a server-side JavaScript runtime. You can talk to it from your client-side JavaScript code, but it's up to your client-side JavaScript code to send the right data.
If all you want to do is convert a JavaScript object or array in memory in your JavaScript engine into JSON, then you just need the JSON.Stringify method.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
This is not node-specific; it's plain basic JavaScript, so you can do it in any JavaScript runtime (including node, but also including the ones running in your browser, if that's where this code is going to run).
var list = ['hello', 'world']
var listAsJson = JSON.stringify(list)
// listAsJson now contains the string '["hello","world"]'