What is the best way to update JSON objects (only some object values) by unique id?
What is the best way to delete JSON objects by unique id?
Wray Johnson (m) 704-293-9008
In XQuery, JSON objects are represented as immutable maps. Please check out the documentations to learn how these data structures can be changed [1,2]. _______________
[1] http://docs.basex.org/wiki/Map_Module [2] https://www.w3.org/TR/xpath-functions-31/#maps-and-arrays
On Sun, Nov 12, 2017 at 3:42 AM, E. Wray Johnson wray.johnson@gmail.com wrote:
What is the best way to update JSON objects (only some object values) by unique id?
What is the best way to delete JSON objects by unique id?
Wray Johnson (m) 704-293-9008
Christian,
The JSON Module suggests that JSON objects are represented as XML-documents with a certain structure, not as immutable maps. Is there support in BaseX for json:parse and json:serialize for parsing JSON in textual form into immutable maps and back to JSON in textual form?
Kind regards, Maurice van Keulen
--
----------------------------------------------------------------------
Dr.Ir. M. van Keulen - Associate Professor, Data Management Technology
Univ. of Twente, Dept of EEMCS, POBox 217, 7500 AE Enschede, Netherlands
Email: m.vankeulen@utwente.nlmailto:m.vankeulen@utwente.nl, Phone: +31 534893688, Fax: +31 534892927
Room: ZI 2013, WWW: http://www.cs.utwente.nl/~keulen
On 13 Nov 2017 23:31 +0100, Christian Grün christian.gruen@gmail.com, wrote: In XQuery, JSON objects are represented as immutable maps. Please check out the documentations to learn how these data structures can be changed [1,2]. _______________
[1] http://docs.basex.org/wiki/Map_Module [2] https://www.w3.org/TR/xpath-functions-31/#maps-and-arrays
On Sun, Nov 12, 2017 at 3:42 AM, E. Wray Johnson wray.johnson@gmail.com wrote: What is the best way to update JSON objects (only some object values) by unique id?
What is the best way to delete JSON objects by unique id?
Wray Johnson (m) 704-293-9008
Hi all,
I think we should make the difference between memory and persisted JSON representations.
From what I know, only a JSON document representation will be persisted, And map representations are only memory ones.
Just use the map (or xquery starting v9) format option at parsing time.
Best regards,
Fabrice
De : basex-talk-bounces@mailman.uni-konstanz.de [mailto:basex-talk-bounces@mailman.uni-konstanz.de] De la part de m.vankeulen@utwente.nl Envoyé : mercredi 15 novembre 2017 08:30 À : wray.johnson@gmail.com; christian.gruen@gmail.com Cc : basex-talk@mailman.uni-konstanz.de Objet : Re: [basex-talk] Update/Delete JSON
Christian,
The JSON Module suggests that JSON objects are represented as XML-documents with a certain structure, not as immutable maps. Is there support in BaseX for json:parse and json:serialize for parsing JSON in textual form into immutable maps and back to JSON in textual form?
Kind regards, Maurice van Keulen
--
----------------------------------------------------------------------
Dr.Ir. M. van Keulen - Associate Professor, Data Management Technology
Univ. of Twente, Dept of EEMCS, POBox 217, 7500 AE Enschede, Netherlands
Email: m.vankeulen@utwente.nlmailto:m.vankeulen@utwente.nl, Phone: +31 534893688, Fax: +31 534892927
Room: ZI 2013, WWW: http://www.cs.utwente.nl/~keulen
On 13 Nov 2017 23:31 +0100, Christian Grün <christian.gruen@gmail.commailto:christian.gruen@gmail.com>, wrote:
In XQuery, JSON objects are represented as immutable maps. Please check out the documentations to learn how these data structures can be changed [1,2]. _______________
[1] http://docs.basex.org/wiki/Map_Module [2] https://www.w3.org/TR/xpath-functions-31/#maps-and-arrays
On Sun, Nov 12, 2017 at 3:42 AM, E. Wray Johnson <wray.johnson@gmail.commailto:wray.johnson@gmail.com> wrote:
What is the best way to update JSON objects (only some object values) by unique id?
What is the best way to delete JSON objects by unique id?
Wray Johnson (m) 704-293-9008
Hi Maurice,
Depending on the chosen format, different outputs will be generated by json:parse. Traditionally, it is true that only XML was generated by this function, but in newer versions (and in alignment with the XQuery 3.1 specs and the fn:parse-json function), it is also possible now to convert JSON data to atomic XQuery items (maps, arrays, strings, numbers and booleans) [1,2]. The resulting representation will be more memory-efficient, and access to XQuery maps is blazing fast, but it won’t be possible to store this representation to a database.
Hope this helps, greetings, Christian
[1] http://docs.basex.org/wiki/JSON_Module#XQuery [2] http://docs.basex.org/wiki/JSON_Module#XQuery_Format
On Wed, Nov 15, 2017 at 8:30 AM, m.vankeulen@utwente.nl wrote:
Christian,
The JSON Module suggests that JSON objects are represented as XML-documents with a certain structure, not as immutable maps. Is there support in BaseX for json:parse and json:serialize for parsing JSON in textual form into immutable maps and back to JSON in textual form?
Kind regards, Maurice van Keulen
--
Dr.Ir. M. van Keulen - Associate Professor, Data Management Technology
Univ. of Twente, Dept of EEMCS, POBox 217, 7500 AE Enschede, Netherlands
Email: m.vankeulen@utwente.nl, Phone: +31 534893688, Fax: +31 534892927
Room: ZI 2013, WWW: http://www.cs.utwente.nl/~keulen
On 13 Nov 2017 23:31 +0100, Christian Grün christian.gruen@gmail.com, wrote:
In XQuery, JSON objects are represented as immutable maps. Please check out the documentations to learn how these data structures can be changed [1,2]. _______________
[1] http://docs.basex.org/wiki/Map_Module [2] https://www.w3.org/TR/xpath-functions-31/#maps-and-arrays
On Sun, Nov 12, 2017 at 3:42 AM, E. Wray Johnson wray.johnson@gmail.com wrote:
What is the best way to update JSON objects (only some object values) by unique id?
What is the best way to delete JSON objects by unique id?
Wray Johnson (m) 704-293-9008
On 11/15/17, 4:24 AM, "basex-talk-bounces@mailman.uni-konstanz.de on behalf of Christian Grün" <basex-talk-bounces@mailman.uni-konstanz.de on behalf of christian.gruen@gmail.com> wrote:
Hi Maurice,
Depending on the chosen format, different outputs will be generated by json:parse. Traditionally, it is true that only XML was generated by this function, but in newer versions (and in alignment with the XQuery 3.1 specs and the fn:parse-json function), it is also possible now to convert JSON data to atomic XQuery items (maps, arrays, strings, numbers and booleans) [1,2]. The resulting representation will be more memory-efficient, and access to XQuery maps is blazing fast, but it won’t be possible to store this representation to a database.
Hope this helps, greetings, Christian
[1] https://urldefense.proofpoint.com/v2/url?u=http-3A__docs.basex.org_wiki_JSON... [2] https://urldefense.proofpoint.com/v2/url?u=http-3A__docs.basex.org_wiki_JSON...
On Wed, Nov 15, 2017 at 8:30 AM, m.vankeulen@utwente.nl wrote: > Christian, > > The JSON Module suggests that JSON objects are represented as XML-documents > with a certain structure, not as immutable maps. Is there support in BaseX > for json:parse and json:serialize for parsing JSON in textual form into > immutable maps and back to JSON in textual form? > > Kind regards, > Maurice van Keulen
Aside from XQuery and BaseX converting JSON, because JSON is not just objects, I think there could be a problem with the concept of converting JSON to maps, also. For example, these JSON documents aren’t map-like:
1. true 2. ["a", "a", "a", "x"]
Kendall
Aside from XQuery and BaseX converting JSON, because JSON is not just objects, I think there could be a problem with the concept of converting JSON to maps, also. For example, these JSON documents aren’t map-like:
- true
- ["a", "a", "a", "x"]
True! In the current version of BaseX, the option for converting JSON to XQuery item is still called 'map'. This is confusing, so (with BaseX 9.0) we changed it to 'xquery'.
Christian,
Can you give an example of how to convert JSON data to atomic XQuery items (sepecifically strings, numbers and booleans)? Is it as simple as removing the curly brackets to bound an object?
On Wed, Nov 15, 2017 at 11:05 AM, Kendall Shaw kendall.shaw@workday.com wrote:
On 11/15/17, 4:24 AM, "basex-talk-bounces@mailman.uni-konstanz.de on behalf of Christian Grün" <basex-talk-bounces@mailman.uni-konstanz.de on behalf of christian.gruen@gmail.com> wrote:
Hi Maurice, Depending on the chosen format, different outputs will be generated by json:parse. Traditionally, it is true that only XML was generated by this function, but in newer versions (and in alignment with the XQuery 3.1 specs and the fn:parse-json function), it is also possible now to convert JSON data to atomic XQuery items (maps, arrays, strings, numbers and booleans) [1,2]. The resulting representation will be more memory-efficient, and access to XQuery maps is blazing fast, but it won’t be possible to store this representation to a database. Hope this helps, greetings, Christian [1] https://urldefense.proofpoint.com/v2/url?u=http-3A__docs.
basex.org_wiki_JSON-5FModule-23XQuery&d=DwIFaQ&c=DS6PUFBBr_ KiLo7Sjt3ljp5jaW5k2i9ijVXllEdOozc&r=JgwnBEpN1c-DDmq- Up2QMq9rrGyfWK0KtSpT7dxRglA&m=gYEI_kXgIHiAXP9cz0NdqkWgkjfpAGxnOd1 -b8pW3mo&s=_ugHBUSWLu-V4vzcR6jpfcc11M-g6zbiag5lU7COcLA&e= [2] https://urldefense.proofpoint.com/v2/url?u=http-3A__docs. basex.org_wiki_JSON-5FModule-23XQuery-5FFormat&d=DwIFaQ&c=DS6PUFBBr_ KiLo7Sjt3ljp5jaW5k2i9ijVXllEdOozc&r=JgwnBEpN1c-DDmq- Up2QMq9rrGyfWK0KtSpT7dxRglA&m=gYEI_kXgIHiAXP9cz0NdqkWgkjfpAGxnOd1 -b8pW3mo&s=o-pnuPNeYd74pBg0DLEEtwO3r4IKsaC7DPGIo7gxG6c&e=
On Wed, Nov 15, 2017 at 8:30 AM, <m.vankeulen@utwente.nl> wrote: > Christian, > > The JSON Module suggests that JSON objects are represented as
XML-documents > with a certain structure, not as immutable maps. Is there support in BaseX > for json:parse and json:serialize for parsing JSON in textual form into > immutable maps and back to JSON in textual form? > > Kind regards, > Maurice van Keulen
Aside from XQuery and BaseX converting JSON, because JSON is not just objects, I think there could be a problem with the concept of converting JSON to maps, also. For example, these JSON documents aren’t map-like:
- true
- ["a", "a", "a", "x"]
Kendall
Hi E. Wray,
Can you give an example of how to convert JSON data to atomic XQuery items (sepecifically strings, numbers and booleans)?
Sure:
let $options := map { 'format': 'map' } for $json in ( '"string"', '1984', 'true' ) return json:parse($json, $options)
With BaseX 9.0, you’ll need to change 'map' to 'xquery'. You can also use fn:parse-json without second argument (see [1] for more examples).
Cheers, Christian
[1] https://www.w3.org/TR/xpath-functions-31/#func-parse-json
On Wed, Nov 15, 2017 at 6:26 PM, E. Wray Johnson wray.johnson@gmail.com wrote:
Christian,
Can you give an example of how to convert JSON data to atomic XQuery items (sepecifically strings, numbers and booleans)? Is it as simple as removing the curly brackets to bound an object?
On Wed, Nov 15, 2017 at 11:05 AM, Kendall Shaw kendall.shaw@workday.com wrote:
On 11/15/17, 4:24 AM, "basex-talk-bounces@mailman.uni-konstanz.de on behalf of Christian Grün" <basex-talk-bounces@mailman.uni-konstanz.de on behalf of christian.gruen@gmail.com> wrote:
Hi Maurice, Depending on the chosen format, different outputs will be generated by json:parse. Traditionally, it is true that only XML was generated by this function, but in newer versions (and in alignment with the XQuery 3.1 specs and the fn:parse-json function), it is also possible now to convert JSON data to atomic XQuery items (maps, arrays, strings, numbers and booleans) [1,2]. The resulting representation will be more memory-efficient, and access to XQuery maps is blazing fast, but it won’t be possible to store this representation to a database. Hope this helps, greetings, Christian [1]
https://urldefense.proofpoint.com/v2/url?u=http-3A__docs.basex.org_wiki_JSON... [2] https://urldefense.proofpoint.com/v2/url?u=http-3A__docs.basex.org_wiki_JSON...
On Wed, Nov 15, 2017 at 8:30 AM, <m.vankeulen@utwente.nl> wrote: > Christian, > > The JSON Module suggests that JSON objects are represented as
XML-documents > with a certain structure, not as immutable maps. Is there support in BaseX > for json:parse and json:serialize for parsing JSON in textual form into > immutable maps and back to JSON in textual form? > > Kind regards, > Maurice van Keulen
Aside from XQuery and BaseX converting JSON, because JSON is not just objects, I think there could be a problem with the concept of converting JSON to maps, also. For example, these JSON documents aren’t map-like:
- true
- ["a", "a", "a", "x"]
Kendall
basex-talk@mailman.uni-konstanz.de