bluelinelabs / bluelinelabs/LoganSquare

Update existing object with json data

Open
#157 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
3.2k
Forks
303
PR merge metrics
No merged PRs in 30d

Description

Currently there is no way to insert json data to an object that already exists.

It would be great to be able to do as below (use case for Realm):

``` java
@JsonObject
public class MyObject extends RealmObject {
@JsonField
@JsonObjectId
String id;

@JsonField
int someField;

@JsonField
String anotherField;

@OnJsonIdRead
MyObject onJsonIdRead(String id){
return MyRealmManager.getRealm().where(MyObject.class).equalTo("id", id).findFirst();
}
}
```

It would solve a problem with server returning different versions of json i.e. we already have `id` and `anotherField`, but in some call server returns only `id` and `someField`. Realm can't help with it's `createOrUpdateAllFromJson()`.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing the Realm createOrUpdateAllFromJson() use case and the @OnJsonIdRead example in the issue. Define how an existing object is found by its JSON id and how partial JSON updates preserve fields omitted from the response; done means this behavior is supported without losing existing values.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
mobile-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.