question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

jsonpath as key accessor

See original GitHub issue

is it possible use jsonpath as key accessor? somethings like this:

{
  "id" : $content.container[0].component[?(@.componentType==1)].id
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:15

github_iconTop GitHub Comments

1reaction
catullcommented, Oct 26, 2019

I prefer the first option.

Reasoning:

  • The question mark is a good symbolic indicator of a boolean evaluation (“Is it true or false”)
  • The second choice “ties” the question mark to component, kind of existential. ("Is there an attribute named component, yes or no ?)
  • The third option is too generic, it denotes a calculation, similar to expressions in shell scripts. It just so happens to evaluate to a boolean. It could be used for a dynamic calculation, though.

However, I also like the curly braces I mentioned. But, out of consistency that indexing and evaluation happen to be in square brackets, I vote for your first option, hanving an expression that produces true/false coated in-between [? and ].

0reactions
larsgacommented, Oct 26, 2019

Well, I didn’t understand the initial question, and I still don’t, so I can’t really answer it. What “JSON path expressions” are being asked for that the language doesn’t have?

Read more comments on GitHub >

github_iconTop Results From Across the Web

JSON Member Accessors
A member accessor specifies the JSON object keys whose values are to be returned. A $ represents the entire object and is optionally...
Read more >
jsonpath - IBM
A member accessor that returns an object member with the specified key. If the key name is a named variable starting with $...
Read more >
Accessing JSON value when key has special character
In an angular controller, I call this JSON object data.topalbums.album . Back in my HTML page, I'm trying to insert the last (3rd)...
Read more >
12: 9.15. JSON Functions and Operators - PostgreSQL
The || operator concatenates two JSON objects by generating an object containing the union of their keys, taking the second object's value when...
Read more >
JSON path: descendant accessor ..<key> - Modern SQL
JSON path : descendant accessor ..<key>. BigQuery Db2 (LUW) MariaDB MySQL Oracle DB PostgreSQL SQL Server SQLite 2005 2007 2009 2011 2013 2015...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found