adriank / ObjectPath

The agile query language for semi-structured data
http://objectpath.org
MIT License
380 stars 93 forks source link

Can't interpret object keys which contain ":" #42

Closed richard-jones closed 8 years ago

richard-jones commented 8 years ago

I have a JSON-LD style document that contains ":" as a namespace separator in the object's keys, so something like:

{
    "dc:identifier" : [{"type" : "identifier type", "id" : "identifier"}]
}

When I do

t = Tree(doc)
t.execute("$.dc:identifier")

I get nothing back.

If I add a key which does not have a ":" it works fine, so I guess that's the reason.

I couldn't see if ":" is a special character in objectpath, and I couldn't find an escape character to use from the documentation, so a bit stuck. A shame, as it does everything else I need!

adriank commented 8 years ago

t.execute("$.'dc:identifier'") should solve that. :)

Greetings, Adrian Kalbarczyk

http://kalbarczyk.co http://about.me/akalbarczyk

On Wed, Feb 10, 2016 at 6:22 PM, Richard Jones notifications@github.com wrote:

I have a JSON-LD style document that contains ":" as a namespace separator in the object's keys, so something like:

{ "dc:identifier" : [{"type" : "identifier type", "id" : "identifier"}] }

When I do

t = Tree(doc) t.execute("$.dc:identifier")

I get nothing back.

If I add a key which does not have a ":" it works fine, so I guess that's the reason.

I couldn't see if ":" is a special character in objectpath, and I couldn't find an escape character to use from the documentation, so a bit stuck. A shame, as it does everything else I need!

— Reply to this email directly or view it on GitHub https://github.com/adriank/ObjectPath/issues/42.

richard-jones commented 8 years ago

Excellent! Works nicely, thank you :)