Graziano Dimatteo Graziano Dimatteo - 7 days ago 4x
Node.js Question

Nodejs how to use map of object?

Hi i have a json like this called body:

{data: {id:1, name:hallo},
{next: "abc" }

so i have to save it into a map and then i ll need to print or to modify it.
If i save it with this code

var Map = require("collections/map");

var new_body = JSON.parse(body)
var map = new Map(new_body);

i have some difficulties to print for example, how can i do it? maybe i had to define a structure of that map before inserting the json inside it, i don't know...


Your json have errors. Correct them like this.

  "data": {
    "id": 1,
    "name": "hallo"
  "paging": {
    "cursors": {
      "next": "abc"

Then you can parse the json like this and get the value.

var map = JSON.parse(body);//This will parse the json string

Now will have the value "abc"