Proposal - val
and context replacements
#18
Replies: 8 comments 23 replies
-
I'm flagging this as "draft"; I'd like to request input on |
Beta Was this translation helpful? Give feedback.
-
Couple of remarks w.r.t.
|
Beta Was this translation helpful? Give feedback.
-
A note, potentially for another proposal 😬. It also seems likely to me that if we introduce I know we're aiming to keep operator introductions low, but if we're deprecating 3 operators... 😅 |
Beta Was this translation helpful? Give feedback.
-
Hey folks, I've revised the proposal a bit. At the moment, I've included all three operators:
We could choose to separate |
Beta Was this translation helpful? Give feedback.
-
I'm undrafting this, @json-logic/tc, @rmannibucau Do y'all have any thoughts / objections? I'm voting with a This is a bit of a leap, so I'm going to try to aim for an aggregate score of 4 before proceeding (existing voting rules apply, but I'm hoping for decent consensus on this). To clarify, community votes count towards the aggregate score. Community objections will also be noted, and consensus will be sought out. This proposal is the result of a community objection. |
Beta Was this translation helpful? Give feedback.
-
Just so the RFC 6901 option doesn't live in isolation, maybe it's a good idea to include RFC 9535 (JSON Path) as another option. |
Beta Was this translation helpful? Give feedback.
-
I believe this proposal has met the TC criteria to move forward; so I'm marking it as approved, but I'd like @toddbaert to weigh in and give the community some time to voice any objections. TC Votes
With While I'd like to settle one more proposal (deciding if we're going to support implicit application / operator chaining), I think this opens the door for us to begin the process of evaluating each existing operator. |
Beta Was this translation helpful? Give feedback.
-
Important While I failed to explicitly communicate it, the tests codify that JSON Logic uses zero-based indexing for This detail will be important to include in the RFC / formal specification we produce. |
Beta Was this translation helpful? Give feedback.
-
Background
Hey folks! I expect this to be one of the more difficult proposals.
Some previous discussions:
And some commentary here:
Getting to the point:
var
,missing
andmissing_some
are controversial operators.They are controversial because:
var
with improvements without reinventing RFC6901.Proposal
var
,missing
andmissing_some
into the "Legacy" extension for JSON Logic. This means excluding them from the JSON Logic Core RFC. As a community extension, they still appear in Compat Tables.val
val
could be an operator where you explicitly define the path in the arguments, making it more AST-like.By doing this, you could more easily chain things to
val
, like anrfc6901
custom operator,{ "val": { "rfc6901": "/hello/world" } }
Another operator we might introduce is
exists
, which receives the same arguments asval
, but returns aboolean
One more operator we'd probably want to introduce is
??
or "coalesce", which is similar to "or", but performs a nullish check rather than a truthiness check. Very similar to https://www.geeksforgeeks.org/postgresql-coalesce/Arguments
number
/string
are used as pathing argumentsarray
is something I'd like to leave as placeholder, likely for scope control.null
/boolean
/object
are defined as error behavior. I'd like to discuss how we test for errors in another proposal.Test Cases / Showing how the Operators Work
val
exists
??
Probable Objections
val
use RFC6901?This... is a reasonable alternative. I assume this will be debated, but I like the
AST
-like nature this enables here, and I like how this allows us to avoid embedding a string parsing spec.Out of Scope
Scopes
Scopes are out of scope for this proposal. I have experimented with a syntax for this,
This would ascend two scopes to get "hello", but this is not part of this specific proposal.
Beta Was this translation helpful? Give feedback.
All reactions