Title: Easy way to unmarshall/dump objects to Json? · Issue #298 · googleapis/python-bigquery · GitHub
Open Graph Title: Easy way to unmarshall/dump objects to Json? · Issue #298 · googleapis/python-bigquery
X Title: Easy way to unmarshall/dump objects to Json? · Issue #298 · googleapis/python-bigquery
Description: Sorry if I missed it, but could not find it in the documentation or after playing around. Basically I am trying to get the raw json dump of objects like Tables or TableList, but via the API we are getting many composed objects that need ...
Open Graph Description: Sorry if I missed it, but could not find it in the documentation or after playing around. Basically I am trying to get the raw json dump of objects like Tables or TableList, but via the API we are ...
X Description: Sorry if I missed it, but could not find it in the documentation or after playing around. Basically I am trying to get the raw json dump of objects like Tables or TableList, but via the API we are ...
Opengraph URL: https://github.com/googleapis/python-bigquery/issues/298
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Easy way to unmarshall/dump objects to Json?","articleBody":"Sorry if I missed it, but could not find it in the documentation or after playing around. \r\n\r\nBasically I am trying to get the raw json dump of objects like Tables or [TableList](https://cloud.google.com/bigquery/docs/reference/rest/v2/tables/list#response-body), but via the API we are getting many composed objects that need to be unmarshalled manually one by one.\r\n\r\nFor example: what would be a way to dump into json a TableList? Thanks!\r\n\r\n```\r\nfrom google.cloud import bigquery\r\nimport json\r\n\r\nclient = bigquery.Client() \r\n \r\nfor d in client.list_datasets():\r\n for t in client.list_tables(d.reference):\r\n print(t)\r\n print(repr(t))\r\n print(dir(t))\r\n print(t.table_id)\r\n print(json.dumps(t))\r\n```\r\n \r\n \r\n```\r\n\u003cgoogle.cloud.bigquery.table.TableListItem object at 0x7f02c30b0760\u003e\r\n\u003cgoogle.cloud.bigquery.table.TableListItem object at 0x7f02c30b0760\u003e\r\n['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_properties', 'clustering_fields', 'created', 'dataset_id', 'expires', 'friendly_name', 'from_string', 'full_table_id', 'labels', 'partition_expiration', 'partitioning_type', 'project', 'reference', 'table_id', 'table_type', 'time_partitioning', 'to_bqstorage', 'view_use_legacy_sql']\r\narr\r\nTraceback (most recent call last):\r\n File \"\u003cstdin\u003e\", line 7, in \u003cmodule\u003e\r\n File \"/usr/lib/python3.8/json/__init__.py\", line 231, in dumps\r\n return _default_encoder.encode(obj)\r\n File \"/usr/lib/python3.8/json/encoder.py\", line 199, in encode\r\n chunks = self.iterencode(o, _one_shot=True)\r\n File \"/usr/lib/python3.8/json/encoder.py\", line 257, in iterencode\r\n return _iterencode(o, 0)\r\n File \"/usr/lib/python3.8/json/encoder.py\", line 179, in default\r\n raise TypeError(f'Object of type {o.__class__.__name__} '\r\nTypeError: Object of type TableListItem is not JSON serializable\r\n \r\n```\r\n \r\n--\u003e\r\n\r\n`{\"created\":\"2020-10-05T01:43:40.077Z\",\"dataset_id\":\"d\",\"description\":null, ...}`\r\n","author":{"url":"https://github.com/romainr","@type":"Person","name":"romainr"},"datePublished":"2020-10-05T20:08:29.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/298/python-bigquery/issues/298"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:531c6ea6-4a04-0b06-3a0b-2f13844a15c7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E2DE:383777:2A71634:3A8E7CC:6A4EFE5E |
| html-safe-nonce | 2a8943181bd4241475803b81d8c248cac28d721af4a74ca68c59b3b4a71f1542 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMkRFOjM4Mzc3NzoyQTcxNjM0OjNBOEU3Q0M6NkE0RUZFNUUiLCJ2aXNpdG9yX2lkIjoiMjAxMTgwODQ3MTg3NjMwNDQ3OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | c129857ecda4b5664b1a5f3e7a132a8008e11f75180a5f493554ca87015c8593 |
| hovercard-subject-tag | issue:715127449 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/googleapis/python-bigquery/298/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d64d907032bbdaefe997729c0c75ef604a927521c821790d5fc3f957daf3ef03/googleapis/python-bigquery/issues/298 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d64d907032bbdaefe997729c0c75ef604a927521c821790d5fc3f957daf3ef03/googleapis/python-bigquery/issues/298 |
| og:image:alt | Sorry if I missed it, but could not find it in the documentation or after playing around. Basically I am trying to get the raw json dump of objects like Tables or TableList, but via the API we are ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | romainr |
| hostname | github.com |
| expected-hostname | github.com |
| None | b92d11c0aa4a77d54ef4af1078b6a15fb5a70a215b30c4ecf28889d5a8e656d9 |
| turbo-cache-control | no-preview |
| go-import | github.com/googleapis/python-bigquery git https://github.com/googleapis/python-bigquery.git |
| octolytics-dimension-user_id | 16785467 |
| octolytics-dimension-user_login | googleapis |
| octolytics-dimension-repository_id | 226992475 |
| octolytics-dimension-repository_nwo | googleapis/python-bigquery |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 226992475 |
| octolytics-dimension-repository_network_root_nwo | googleapis/python-bigquery |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 2b8f23afb982271f1b22258a94aede67a6b77760 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width