xrstf / rudi

A Lisp-like, embeddable, leightweight, non-Turing complete language to transform JSON datastructures
MIT License
5 stars 1 forks source link

Support custom structs #14

Open xrstf opened 10 months ago

xrstf commented 10 months ago

Currently Rudi works only/best with pure map[string]any, generic datastructures. However it would be nice if one could also just use any kind of Go struct, similar to how Go templates also allow to access fields in structs using reflection.

Structs can of course contain pointer fields and those must be taken care of separately, as most funtions in Rudi do not take pointers (like concat), but Rudi also offers no language elements to dereference a pointer, nor do I intend to add such language elements. My plan is to automatically dereference pointers when evaluating a JSON path, so that if a field is nil, nil is returned, otherwise the dereferenced value.

In general, pointers are discouraged in Rudi and can lead to many hard to troubleshoot side effects. Support for them is on a best effort basis.

xrstf commented 8 months ago

Work on this is slowly progressing in the jsonpath2, jsonpath3 and multipath branches.