s-yadav / jsonQ

A JavaScript library to make manipulation and extraction of data from a JSON very easy and fast.
MIT License
202 stars 69 forks source link

name.path is not a function jsonQ #8

Closed felipexbenevides closed 8 years ago

felipexbenevides commented 8 years ago

i have a problem,

name.path is not a function jsonQ

1 2

s-yadav commented 8 years ago

declaring name variable in global scope, treat the value as name of window, so it tries to typecast any thing in string. So why when you do

var name = family.find('name') //in global space
//name is '[object Object]' as a string

If you try same thing inside a function it will work. Try

(function(){
  var family = jsonQ(jsonObj),
       name = family.find('name');

   console.log(name.path())
}())

Read http://stackoverflow.com/questions/20945498/var-name-produces-strange-result-in-javascript


I will update the docs as it is misleading.