Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As mentioned in <a href="https://stackoverflow.com/questions/15124744/illegalargumentexception-deserializing-generated-objects-with-jsonstring-annot">another post</a>, this is caused by a quirk of the <code>protorpc</code> library. Google's API client libraries expect <code>int64</code> and <code>uint64</code> fields to be strings in JSON since Javascript itself can only handle (due to precision) integers up to <code>2**53</code>.</p> <p>As you can see in the <a href="https://developers.google.com/discovery/v1/type-format" rel="nofollow noreferrer">type-format documentation</a> for Google's "Discovery" API standard, this is what to expect for these types. However, the <code>protorpc</code> library doesn't <a href="https://code.google.com/p/google-protorpc/source/browse/python/protorpc/protojson.py" rel="nofollow noreferrer">currently use</a> the same semantics, and we are still determining the correct way to proceed.</p> <p>So, when you use</p> <pre><code>id = messages.IntegerField(1) </code></pre> <p>you are using the default variant for <code>IntegerField</code>s which is <code>messages.Variant.INT64</code>. This in turn makes the Java client library expect a JSON string such as</p> <pre><code>{'id': '123456789'} </code></pre> <p>when instead the response returned from <code>protorpc</code> is</p> <pre><code>{'id': 123456789} </code></pre> <p>As a temporary work-around for your application, either use</p> <pre><code>id = messages.IntegerField(1, variant=messages.Variant.INT32) </code></pre> <p>or if the size of your IDs need to exceed 32 bits, use:</p> <pre><code>id = messages.StringField(1) </code></pre> <h1>POST-SCRIPT:</h1> <p>While you're at it, I recommend looking at the <a href="http://endpoints-proto-datastore.appspot.com/" rel="nofollow noreferrer">Endpoints Proto Datastore API</a>. We've done a few <a href="http://www.youtube.com/watch?v=9wNRUd9E1jM" rel="nofollow noreferrer">screencasts</a> on it's use.</p> <p>To solve the same issue with <code>endpoints-proto-datastore</code>, you'd import</p> <pre><code>from protorpc import messages from endpoints_proto_datastore.ndb import EndpointsVariantIntegerProperty </code></pre> <p>and use</p> <pre><code>attr1 = EndpointsVariantIntegerProperty(variant=messages.Variant.INT32) </code></pre> <p>for your property.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload