-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
question: support for (in-place) JSON updates #80
Comments
https://github.com/benibela/xidel/blob/master/changelog:
That's because so far only the development branch supports
There is JSONiq base functions jn:* and JSONiq library functions jnlib:*, but as far as updating with JSONiq is concerned, I don't know either. Benito would have to answer that. |
Thanks for the explanation. Following are a few very brief clarifications:
|
All development happens on the head(s)
One concept of XPath is that all values are immutable, and to change something you make a copy of all the other values that you do not want to change. So you call the map:put/remove/merge function on an object, and it returns the new object. There is nothing besides functions Although, Xidel has an an update extension.
JSONiq is deprecated I have implemented the "JSONiq Extension To XQuery" specification, which promised to add JSON support to XQuery, but with XQuery 3.1 already supporting JSON, it has become pointless
I had a new project page that links to the function page. It was online for a while, but it seems it has reverted back to the old page.. |
Thanks for the further explanation. The larger question is what is currently implemented (and stable) in Xidel with respect to updating JSON data? Whether the data is processed as a mutation or construction internally not of much concern, since the objective is simply to write a file with updated data. Are you explaining that Xidel implements JSONiq, but because it also implements XQuery, I should use the latter instead, for writing updated JSON documents? |
https://github.com/benibela/xidel: https://www.videlibri.de/xidel.html#examples:
Xidel is part of Benito's VideLibri tool. Xidel's Github repo is just a copy/mirror of https://sourceforge.net/p/videlibri/code/ci/default/tree/programs/internet/xidel/
Since JSONiq is deprecated I'd say it's better to use XQuery. But how complex are these JSON files of yours? For simple JSON files What are you trying to do?
@benibela This extension also has it's limitations, I think, because does it support arrays?
|
The development version implements everything of XQuery 3.1. It is very stable since it has a large testsuite JSONiq is implemented (except JSONiq update jupd:*), but deprecated. There is no official testsuite to know whether it is stable. And my extension are stable when I use them in my projects There is an option
The selling point of XQuery is that it is an official W3C standard JSONiq is only a "specification"
Not on their own It supports arrays in objects:
|
Based on the recent further clarifications, I am understanding that use of XQuery would be a sensible choice. Would an implementation-independent tutorial, or the specification for XQuery, supply enough information needed for writing queries for correct processing by Xidel? I'm not sure I need to consider the non-standard extensions. Is there is a compelling use case? It seems at this point their main advantage might be the smaller footprint and simpler design. Using the current development builds, do I understand correctly that I may not only express XQuery queries, but also invoke an application switch to automate in-place updates to the source file? Are all of the features under discussion more recent than the last release? |
I asked what you're trying to do. How much and how complex editing needs to be done? The XQuery specification could be enough to do some editing on simple JSONs, but you're probably going to need some complex queries with recursive functions otherwise.
Yes.
As in Xidel 0.9.8, or the latest development build? |
Without qualifying the specific needs, I would expect, from my experience with W3C standards of the same family, that XQuery will be a good fit. Many, but not all, queries will be simply resolving a node from a pattern match of a fixed-length path, and applying an update or append operation.
The question was intended to compare the most recent release (v 0.9.8), versus the development build, with respect to the features under discussion.
I will use the development build. You also mentioned that it would be required for support of in-place file operations. |
Yes, and if you end up not liking Xidel, you can search for other XQuery implementations
I do not have a tutorial. The specification is all there is. (and the specification is split in multiple documents. Reino has linked the functions, the syntax is in another document. out serialization is yet another one ).
Some standard parts are rather ugly. The worst is that you cannot create an object with To change properties of nested objects, you need to call map:put for each step. E.g. to change
with my extensions:
On my personal website, I have a text comparing old Xidel, JSONiq and XQuery 3.1 |
I am hoping it works for me, because my preference is a command-line tool that lets me write queries interactively in the shell without any development work or awkward runtime dependencies.
Let me clarify the sense of the question. I was trying to understand whether knowledge of the standard would be sufficient for use in the application, or whether I also should know about certain implementation-specific limitations. |
when something is in the standard and not optional, it should also be in Xidel It is test-driven development. I start with the simplest implementation, then compare it to the xquery test cases, and make sure it can pass them. This is the current state: testresults.zip |
Just checking. In practice, of course, applications of standards do not always follow the ideal. |
An answer on StackExchange shows examples of updates to JSON documents in Xidel.
I am targeting query-based, in-place updates to JSON files from the command line. (I could handle the details of moving the output to the original file location manually, if in-place support is unavailable.)
I have not seen such support directly documented for Xidel, or even unambiguously explained in the feature list. The feature list mentions JSONiq support, but updates appear to be not available in all implementations, and it is unclear how complete is the Xidel implementation of JSONiq.
It would be helpful to have a guide and reference for the full range of functionality for processing JSON documents by update operations. It seems that at present, however, there is no manual, making it hard to understand the entire feature set and how to use all the functionality.
Would someone mind helping me understand the capabilities in Xidel for functionality as I have described, and point me to any. relevant reference material?
The text was updated successfully, but these errors were encountered: