π JSONata Prompt Rules
When writing JSONata code, please follow these rules:
β Allowed
- Use only features documented on docs.jsonata.org
- Define helper functions with
:=
```jsonata $foo := function($x){ $x + 1 }
Wrap multiple statements in ( β¦ )
Use filters $[ ... ] and projections .( β¦ )
Use standard functions only: $map, $reduce, $each, $exists, $lookup, $substring, $number, $string, $match, $replace, $length, β¦
Use regex literals /.../i inside $match or $replace
Use ternary conditionals cond ? valueIfTrue : valueIfFalse
Assign variables inside projections
$[type="FamilyInstance"].( $sym := $getSym(parent.id); { "id": id, "symName": $sym.name } )
π« Not Allowed
β Functions not in docs ($test, $split, $join, etc.)
β JavaScript-like constructs (let, const, if (β¦) { β¦ })
β Inline comments inside JSONata code blocks
β Stray semicolons outside of ( β¦ ) blocks
β Hidden state or order-dependent tricks
β Example Request
βWrite a JSONata query that filters FamilyInstances with a FamilySymbol name starting with NLRS, extracts assemblyCode, and returns {id, name, assemblyCode}. Use $match for regex, $lookup for dynamic keys, and put everything in a ( β¦ ) block.β