Closed AnneTheAgile closed 7 years ago
Hi,
$ alone is not a proper OP expression. Could you please send me log of tree3.execute("$.store.book[0].price")?
Have you tried to run the code from bare Python 2.7?
Greetings, Adrian Kalbarczyk
http://kalbarczyk.co http://about.me/akalbarczyk
On Thu, Jun 16, 2016 at 4:30 AM, AnneTheAgile notifications@github.com wrote:
I wish to use a python notebook, ie jupyter with this library. I could only get the most trivial example to work. Any ideas? thank you! Anne
This works, returning '1'
from objectpath import * tree1=Tree({"a":1}) tree1.execute("$.a")
None of the complex json example is working;
json3 = '{ "store": { "book": [ { "category": "reference", "author": "Nigel Rees", "title": "Sayings of the Century", "price": 8.95 } ] }}' tree3=Tree(json3) tree3.execute("$") # ("$.store.book[0].price")
/Users/ME/anaconda/envs/py27/lib/python2.7/site-packages/objectpath/core/interpreter.pyc in execute(self, expr) 603 D=self.D 604 if type(expr) in STR_TYPES: --> 605 tree=self.compile(expr) 606 elif type(expr) not in (tuple,list,dict): 607 return expr
/Users/ME/anaconda/envs/py27/lib/python2.7/site-packages/objectpath/core/interpreter.pyc in compile(self, expr) 36 if expr in EXPR_CACHE: 37 return EXPR_CACHE[expr] ---> 38 ret=EXPR_CACHE[expr]=parse(expr,self.D) 39 return ret 40
/Users/ME/anaconda/envs/py27/lib/python2.7/site-packages/objectpath/core/parser.pyc in parse(expr, D) 462 nextToken=tokenize(expr).next 463 token=nextToken() --> 464 r=expression().getTree() 465 if D: 466 print ("PARSE STAGE")
/Users/ME/anaconda/envs/py27/lib/python2.7/site-packages/objectpath/core/parser.pyc in expression(rbp) 443 t=token 444 token=nextToken() --> 445 left=t.nud() 446 while rbp < token.lbp: 447 t=token
/Users/ME/anaconda/envs/py27/lib/python2.7/site-packages/objectpath/core/parser.pyc in nud(self) 276 else: 277 self.fst=token.value --> 278 advance() 279 return self 280
/Users/ME/anaconda/envs/py27/lib/python2.7/site-packages/objectpath/core/parser.pyc in advance(ID) 159 if ID and token.id != ID: 160 raise SyntaxError("Expected %r, got %s"%(ID,token.id)) --> 161 token=nextToken() 162 163 def method(s):
StopIteration:
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/adriank/ObjectPath/issues/44, or mute the thread https://github.com/notifications/unsubscribe/AAKycsSKQnDBiWVX3ILjYID_j7ZQ5yYAks5qMLVOgaJpZM4I2-Gm .
I wish to use a python notebook, ie jupyter with this library. I could only get the most trivial example to work. Any ideas? thank you! Anne
This works, returning '1' http://objectpath.org/tutorial.html
None of the complex json example is working;
I am using;