Skip to content
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

CBL-1680: Phase 1, Add JSON API #24

Merged
merged 3 commits into from
Mar 5, 2021
Merged

CBL-1680: Phase 1, Add JSON API #24

merged 3 commits into from
Mar 5, 2021

Conversation

bmeike
Copy link
Contributor

@bmeike bmeike commented Mar 4, 2021

I believe this is the complete JSON API as spec'ed in https://docs.google.com/document/d/1H0mnutn-XXIADvGT_EjINAOVwt0Ea8vwW70v0i_PO54

There is no implementation here. This is just the API and fixed commenting.

Note that, although not specifically mentioned in the spec, I've updated the interfaces that define the Dictionary and Array APIs

*/
public MutableArray(List<Object> data) {
Copy link
Contributor

@Sandychuang8 Sandychuang8 Mar 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we remove this constructor??

Never mind it's up there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah... I don't think the spec suggests removing this. It seems consistent with the constructors for Document and Dictionary objects.

*/
@NonNull
@Override
public MutableArray setJSON(@NonNull String json) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not ToJSON? Is this because you are following java naming convention?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setJSON() is in the MutableArray. toJSON() is inherited from (immutable) Array.

Is that how you did it?

* Map, Number, null, String, Array, Blob, and Dictionary. The List and Map must contain
* only the above types. Setting the new array content will replace the current data
* including the existing Array and Dictionary objects.
* Populate an array with content from a Map.
Copy link
Contributor

@jayahariv jayahariv Mar 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

confused! Map or List? Argument is List<Object>?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah... it is not totally clear. The idea is that the List can contains Maps or Lists. If it does, those Maps/Lists must contain only the types mentioned above. I've revisited the comments to try to make them clearer.

@@ -82,11 +86,26 @@ public MutableArray(List<Object> data) {
public MutableArray setData(List<Object> data) {
synchronized (lock) {
internalArray.clear();
for (Object obj : data) { internalArray.append(Fleece.toCBLObject(obj)); }
for (Object obj: data) { internalArray.append(Fleece.toCBLObject(obj)); }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add @nonnull to data param as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Definitely

@bmeike bmeike merged commit cd44a48 into master Mar 5, 2021
@bmeike bmeike deleted the feature/CBL-1680 branch March 5, 2021 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants