Keeping map / array identity intact across XPath queries #392
DrRataplan
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In Fore we are exploring how to change JSON data. Mainly setting properties in a map or an array. An intuitive way is to have a query that will retrieve an entry in a map or an array, plus a key (or index) and a new value.
For example:
This can be done as long as FontoXPath keeps the identity of maps and arrays in check. So that for the JSON document
{automobiles: [{maker: 'Honda', model: 'accord', year:'2019'}]}
, the query?automobiles?1
results in a map that is not only deeply equal with the corresponding entry in the input document, but is also the same instance. Mutating that map in JavaScript will then also mutate that entry in the original JSON document.Added benefit is the decreased memory usages because of dramatically fewer clones of maps. This also opens the way for dependency tracking in JSON documents: keeping reference equality more often may make it easier to detect what queries use which properties.
(putting this in discussions in hope of getting feedback and to write down my thoughts)
Beta Was this translation helpful? Give feedback.
All reactions