{"action":"closed","issue":{"url":"https://api.github.com/repos/google/google-api-go-client/issues/70","labels_url":"https://api.github.com/repos/google/google-api-go-client/issues/70/labels{/name}","comments_url":"https://api.github.com/repos/google/google-api-go-client/issues/70/comments","events_url":"https://api.github.com/repos/google/google-api-go-client/issues/70/events","html_url":"https://github.com/google/google-api-go-client/issues/70","id":65758309,"number":70,"title":"Go datastore JSON api Indexed property always true","user":{"login":"gmlewis","id":6598971,"avatar_url":"https://avatars.githubusercontent.com/u/6598971?v=3","gravatar_id":"","url":"https://api.github.com/users/gmlewis","html_url":"https://github.com/gmlewis","followers_url":"https://api.github.com/users/gmlewis/followers","following_url":"https://api.github.com/users/gmlewis/following{/other_user}","gists_url":"https://api.github.com/users/gmlewis/gists{/gist_id}","starred_url":"https://api.github.com/users/gmlewis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gmlewis/subscriptions","organizations_url":"https://api.github.com/users/gmlewis/orgs","repos_url":"https://api.github.com/users/gmlewis/repos","events_url":"https://api.github.com/users/gmlewis/events{/privacy}","received_events_url":"https://api.github.com/users/gmlewis/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/google/google-api-go-client/labels/new","name":"new","color":"FFFFFF"},{"url":"https://api.github.com/repos/google/google-api-go-client/labels/priority-medium","name":"priority-medium","color":"FFFFFF"},{"url":"https://api.github.com/repos/google/google-api-go-client/labels/type-defect","name":"type-defect","color":"FFFFFF"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-04-01T19:16:26Z","updated_at":"2015-04-09T07:26:23Z","closed_at":"2015-04-09T07:26:23Z","body":"\n**ross.hendrickson@workiva.com** on 6 Nov 2014 at 3:41:\n\n```\nI was not sure where to post this question but I figured here was better than \nanywhere else. I've been working on a datastore client for the Google JSON API \nthat wraps around the generated Go code here\n\nhttps://godoc.org/code.google.com/p/google-api-go-client/datastore/v1beta2\n\nMy client eases the ability to construct compliant requests, entities, queries \nas well as provides some configuration and authentication assistance (much as \nthe python an java libraries do). However, I ran into a wrinkle during some \ntesting today. The core of it is how the omitempty tag on the Property struct's \nIndexed field is handled. The behavior is displayed in this play link.\n\nWhat steps will reproduce the problem?\n\nhttp://play.golang.org/p/4t8ZfyncgA\n\nWhat is the expected output? What do you see instead?\nHere is the output of the play\n2009/11/10 23:00:00 A:{BlobValue:Not Omitted Indexed:false}\n2009/11/10 23:00:00 Buff {\"blobValue\":\"Not Omitted\",\"indexed\":false}\n2009/11/10 23:00:00 See how the above has the Indexed property exported?\n2009/11/10 23:00:00 Marshal exports it too {\"blobValue\":\"Not \nOmitted\",\"indexed\":false}\n2009/11/10 23:00:00 What happens if we add omitempty to the Indexed property?\n2009/11/10 23:00:00 B:{BlobValue:Omitted Indexed:false}\n2009/11/10 23:00:00 Buff {\"blobValue\":\"Omitted\"}\n2009/11/10 23:00:00 See how the above does not have the Indexed property \nexported?\n2009/11/10 23:00:00 Marshal does not export it either: {\"blobValue\":\"Omitted\"}\n\nThe issue is that the JSON api itself assumes that indexed = true if you do not \nexplicitly set it to false in the JSON of your request. This is a problem \nbecause Marshaling the structs in the JSON API library will never give you an \nexplicit indexed = false even if you have that set to false on the struct \nbecause the Indexed field is tagged 'omitempty'. I was trying to use the \nstructs from the generated go but I don't see a way to work around this without \njust writing/copying my own verbatim copies of those structs so I can change \nthat single tag. If the indexed field is not in the JSON of the request, \nspecifically for a BlobValue, and the length of the BlobValue is > 500 bytes \nthen you will get a 400 error response telling you that it can't save an \nindexed blob greater than 500 bytes (which is correct and in the docs). Is \nthere anything I might be missing?\n\nHere is a cleaned dump of the requests and response\nhttp://pastebin.com/2t2Twy2Q\n\nWe have previously been constructing our own JSON for our entities and naively \nhad the omitempty tag not on our Indexed property. Now that we're trying to \nmake something that is more flexible we've run into this problem. I'm open to \nsuggestions. Thank you for your time.\n\nRoss\n\nWhat version of the product are you using? Google Datastore JSON API v1betav2, \nGo 1.3.1\nOn what operating system? Linux & OSX\n\n```\n\n\n\n"}}