0

I am trying to read the value of a Json object with a given key. However, my key is a bit complicated thus i get undefined on the console. I am sure i am not using it the right way ? can someone point my mistake ?

Json key: value

relevant=(pooled + assigned + unknown + dropping) : 230

Node.js

    data = JSON.parse(buffer);

    var dump = "  relevant=(pooled + assigned + unknown + dropping)  ";
    console.log(data.totals.dump);
1
  • There is no JSON here... Commented Jul 12, 2014 at 5:11

1 Answer 1

1

First of all you should not call like data.totals.dump it will search for a key dump in data.totals.

use data.totals[dump] instead. Then it'll search for key what is value of dump.

and for key purpose better do once Object.keys(data.totals) to see what are the keys in my object.

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

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.