Long null value from Json

40 views
Skip to first unread message

Bartosz Łuczak

unread,
Feb 20, 2015, 3:17:59 AM2/20/15
to realm...@googlegroups.com
Hi,

I have a problem with put long value from json to te model class. this is example

@RealmClass
public class PostalDelivery extends RealmObject {
private long amountOfCollection;   

    public long getAmountOfCollection() {
        return amountOfCollection;
    }

    public void setAmountOfCollection(long amountOfCollection) {
        this.amountOfCollection = amountOfCollection;
    }

}

When I try:

JSONArray myArray = new JSONArray();
            JSONObject j = new JSONObject();
j.put("amountOfCollection", JSONObject.NULL);
    myArray.put(j);

            realm.beginTransaction();
            realm.createAllFromJson(PostalDelivery.class, myArray);   // HERE IS EXCEPTION
            realm.commitTransaction();

Maybe someone have any idea for this problem.

Regards,
Bartosz Łuczak

Christian Melchior

unread,
Feb 23, 2015, 9:39:14 AM2/23/15
to Bartosz Łuczak, realm...@googlegroups.com
Hi Bartosz

You seem to have stumbled across a bug in our JSON implementation. Null values should be replaced by their default value not throwing an exception.
I plan to create a fix shortly. You can follow progress here: https://github.com/realm/realm-java/pull/890

A work around until we can publish this would be to either omitting fields with NULL values or replace null with the default value for that type, ie. 0 for longs.

--
Christian Melchior
Senior Android Developer


--
You received this message because you are subscribed to the Google Groups "Realm Java" group.
To unsubscribe from this group and stop receiving emails from it, send an email to realm-java+...@googlegroups.com.
To post to this group, send email to realm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/realm-java/1cd42fb4-cd71-4a1d-8315-b1ff692e6572%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



{#HS:72897943-551#}

Bartosz Łuczak

unread,
Feb 24, 2015, 6:21:20 AM2/24/15
to realm...@googlegroups.com, luczak....@gmail.com, he...@realm.io
Hi,

I saw on Github that you fixed this bug. When will be build new library for eclipse with this correction?

Regards,
Bartosz Łuczak

Christian Melchior

unread,
Feb 24, 2015, 9:38:19 AM2/24/15
to Bartosz Łuczak, realm...@googlegroups.com
Hi

I have just merged the fix to master. You should be able to get it in our 0.79.2-SNAPSHOT build (in 10 minutes) until we can release a proper version.

Happy coding.


--
Christian Melchior
Senior Android Developer


On Tue, Feb 24, 2015 at 11:21 AM UTC, Bartosz Łuczak <luczak....@gmail.com> wrote:
Hi,

{#HS:72897943-551#}

Bartosz Łuczak

unread,
Feb 25, 2015, 9:07:45 AM2/25/15
to realm...@googlegroups.com, luczak....@gmail.com, he...@realm.io
Hi,

When Can I expect version 0.79.2, because i can't find 0.79.2-SNAPSHOT.

Regards,
Bartosz Łuczak

Christian Melchior

unread,
Feb 25, 2015, 9:10:04 AM2/25/15
to Bartosz Łuczak, realm...@googlegroups.com
Ah sorry.

You need to point to another repository. If you use the following repositories block in your app/build.gradle, it should work:

repositories {
jcenter()
maven {
url 'http://oss.jfrog.org/artifactory/oss-snapshot-local'

}
}


--
Christian Melchior
Senior Android Developer


On Wed, Feb 25, 2015 at 2:07 PM UTC, Bartosz Łuczak <luczak....@gmail.com> wrote:
Hi,

{#HS:72897943-551#}
Reply all
Reply to author
Forward
0 new messages