{"action":"created","issue":{"url":"https://api.github.com/repos/chrsmith/google-api-java-client/issues/437","labels_url":"https://api.github.com/repos/chrsmith/google-api-java-client/issues/437/labels{/name}","comments_url":"https://api.github.com/repos/chrsmith/google-api-java-client/issues/437/comments","events_url":"https://api.github.com/repos/chrsmith/google-api-java-client/issues/437/events","html_url":"https://github.com/chrsmith/google-api-java-client/issues/437","id":59377197,"number":437,"title":"Generate Base64 encoding/decoding of byte[]<->JSON String","user":{"login":"GoogleCodeExporter","id":9614759,"avatar_url":"https://avatars.githubusercontent.com/u/9614759?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCodeExporter","html_url":"https://github.com/GoogleCodeExporter","followers_url":"https://api.github.com/users/GoogleCodeExporter/followers","following_url":"https://api.github.com/users/GoogleCodeExporter/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCodeExporter/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCodeExporter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCodeExporter/subscriptions","organizations_url":"https://api.github.com/users/GoogleCodeExporter/orgs","repos_url":"https://api.github.com/users/GoogleCodeExporter/repos","events_url":"https://api.github.com/users/GoogleCodeExporter/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCodeExporter/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/chrsmith/google-api-java-client/labels/auto-migrated","name":"auto-migrated","color":"ededed"},{"url":"https://api.github.com/repos/chrsmith/google-api-java-client/labels/Component-Google-APIs","name":"Component-Google-APIs","color":"ededed"},{"url":"https://api.github.com/repos/chrsmith/google-api-java-client/labels/Milestone-Version1.14.0","name":"Milestone-Version1.14.0","color":"ededed"},{"url":"https://api.github.com/repos/chrsmith/google-api-java-client/labels/Priority-Medium","name":"Priority-Medium","color":"ededed"},{"url":"https://api.github.com/repos/chrsmith/google-api-java-client/labels/Type-Enhancement","name":"Type-Enhancement","color":"ededed"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-03-01T04:08:57Z","updated_at":"2015-03-01T04:08:59Z","closed_at":"2015-03-01T04:08:57Z","body":"```\nExternal references, such as a standards document, or specification?\n\nhttp://code.google.com/apis/discovery/v1/reference.html#type-and-format-summary\n\nJava environments (e.g. Java 6, Android 2.3, App Engine, or All)?\n\nAll\n\nPlease describe the feature requested.\n\nSome Google API services may include a data type that is a base64-encoded \nstring of bytes.  It is the data type listed in the above reference link as \ntype value \"string\" and format value \"byte\".  It is not documented there, but \napparently this is the URL-safe alphabet with padding.  We should make it \neasier to parse/serialize that format.\n\nThe catch is the lower-level JSON model doesn't have this support built-in.  \nThe simplest solution is to still use Java String as the data type of the \nfield, but provide accessors that handle that conversion and work with byte[].\n\nSo one option:\n\npublic class A {\n  @Key private String data;\n  public byte[] getData() {\n    return Base64.decodeBase64(data);\n  }\n  public void setData(byte[] data) {\n    this.data = Base64.encodeBase64URLSafeString(data);\n  }\n}\n\nAnother option:\n\npublic class A {\n  @Key private String data;\n  public String getData() {\n    return data;\n  }\n  public void setData(String data) {\n    this.data = data;\n  }\n  public byte[] decodeData() {\n    return Base64.decodeBase64(data);\n  }\n  public void encodeData(byte[] data) {\n    this.data = Base64.encodeBase64URLSafeString(data);\n  }\n}\n\n(or something along these lines)\n```\n\nOriginal issue reported on code.google.com by `yan...@google.com` on 26 Mar 2012 at 6:27"},"comment":{"url":"https://api.github.com/repos/chrsmith/google-api-java-client/issues/comments/76572426","html_url":"https://github.com/chrsmith/google-api-java-client/issues/437#issuecomment-76572426","issue_url":"https://api.github.com/repos/chrsmith/google-api-java-client/issues/437","id":76572426,"user":{"login":"GoogleCodeExporter","id":9614759,"avatar_url":"https://avatars.githubusercontent.com/u/9614759?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCodeExporter","html_url":"https://github.com/GoogleCodeExporter","followers_url":"https://api.github.com/users/GoogleCodeExporter/followers","following_url":"https://api.github.com/users/GoogleCodeExporter/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCodeExporter/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCodeExporter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCodeExporter/subscriptions","organizations_url":"https://api.github.com/users/GoogleCodeExporter/orgs","repos_url":"https://api.github.com/users/GoogleCodeExporter/repos","events_url":"https://api.github.com/users/GoogleCodeExporter/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCodeExporter/received_events","type":"User","site_admin":false},"created_at":"2015-03-01T04:08:59Z","updated_at":"2015-03-01T04:08:59Z","body":"```\nNew reference link:\n\nhttps://developers.google.com/discovery/v1/type-format?hl=en\n\nExample use case:\n\nhttps://www.googleapis.com/discovery/v1/apis/storage/v1beta2/rest?fields=schemas\n/Object/properties/media/properties/data\n```\n\nOriginal comment by `yan...@google.com` on 12 Jan 2013 at 3:48"}}