zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #04737
[Bug 928710] Re: No way to populate JSON array with atomic values via store API
The public ItemFactory works as Matthias suggests: It accepts a
vector<Item> of members to put into the array. After creation, it is not
possible to modify JSON objects or arrays via the public API.
I have changed the implementation of ItemFactory::createJSONArray() to
use Store::populateJSONArray() and it works, so the urgency behind the
original bug report is gone (thanks!). I've re-purposed this bug to
track the issue Matthias raised; see the new bug description.
** Changed in: zorba
Importance: Critical => Medium
** Changed in: zorba
Milestone: 2.2 => None
** Changed in: zorba
Assignee: Chris Hillery (ceejatec) => Markos Zaharioudakis (markos-za)
** Summary changed:
- No way to populate JSON array with atomic values via store API
+ Populating JSON array requires direct store manipulation
** Description changed:
- If you are creating JSON items via the store API, the only way to add
- members to an array is to use the "no-copy copy()" trick, calling copy()
- on the member Item and passing a store::CopyMode with theDoCopy set to
- false.
+ New bug description:
+ The only way to create a JSON array item with members is to first create the item, then populate it by manipulating the store using Store::populateJSONArray(). This seems like a bad API as only update primitives should be actually manipulating the store. (The way you create a JSON object with pairs is similar - you create the JSONObject item first, then "copy" pairs into it. This "copy" method also seems problematic as it can be done at any time, and really should only be used by update primitives.)
+
+
+ Original bug description:
+ If you are creating JSON items via the store API, the only way to add members to an array is to use the "no-copy copy()" trick, calling copy() on the member Item and passing a store::CopyMode with theDoCopy set to false.
However, copy() is not implemented for Items of atomic types (at least
integer and string), so there is no way at all to create a JSON array
with strings or integers as members. This of course means there's no way
to do it with the public C++ API either.
--
You received this bug notification because you are a member of Zorba
Coders, which is the registrant for Zorba.
https://bugs.launchpad.net/bugs/928710
Title:
Populating JSON array requires direct store manipulation
Status in Zorba - The XQuery Processor:
New
Bug description:
New bug description:
The only way to create a JSON array item with members is to first create the item, then populate it by manipulating the store using Store::populateJSONArray(). This seems like a bad API as only update primitives should be actually manipulating the store. (The way you create a JSON object with pairs is similar - you create the JSONObject item first, then "copy" pairs into it. This "copy" method also seems problematic as it can be done at any time, and really should only be used by update primitives.)
Original bug description:
If you are creating JSON items via the store API, the only way to add members to an array is to use the "no-copy copy()" trick, calling copy() on the member Item and passing a store::CopyMode with theDoCopy set to false.
However, copy() is not implemented for Items of atomic types (at least
integer and string), so there is no way at all to create a JSON array
with strings or integers as members. This of course means there's no
way to do it with the public C++ API either.
To manage notifications about this bug go to:
https://bugs.launchpad.net/zorba/+bug/928710/+subscriptions
References