Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shnewto/bqjson
bqjson - Serialize/Deserialzie BigQuery TableResults to/from JSON
https://github.com/shnewto/bqjson
bigquery java json maven serde serde-json serialization serializer tableresult testing tests
Last synced: 3 months ago
JSON representation
bqjson - Serialize/Deserialzie BigQuery TableResults to/from JSON
- Host: GitHub
- URL: https://github.com/shnewto/bqjson
- Owner: shnewto
- License: mit
- Created: 2020-12-10T05:34:28.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-02-01T15:04:00.000Z (almost 4 years ago)
- Last Synced: 2024-10-09T06:40:59.499Z (4 months ago)
- Topics: bigquery, java, json, maven, serde, serde-json, serialization, serializer, tableresult, testing, tests
- Language: Java
- Homepage:
- Size: 529 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
[![GitHub Actions build](https://github.com/shnewto/bqjson/workflows/build/badge.svg?branch=main)](https://github.com/shnewto/bqjson/actions?query=workflow%3ACI)
[![Maven Central](https://img.shields.io/maven-central/v/com.github.shnewto/bqjson.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.github.shnewto%22%20AND%20a:%22bqjson%22)# bqjson
Serialize/Deserialize BigQuery TableResults (and TableResult adjacent types) to/from JSON.# Example
```java
package com.github.shnewto.bqjson.SerDe;
/* ... */class MyBigQueryService {
void myBigQueryWork() {
/* Get a table result from BigQuery */
TableResult originalTableResult = bigQuery
.create(JobInfo.newBuilder(queryConfig)
.setJobId(jobId).build())
.waitFor()
.getQueryResults();
/* Serialize TableResult to JSON */
String jsonString = SerDe.toJson(originalTableResult);
/* Deserialize the JSON back into a TableResult */
TableResult reconstitutedTableResult = SerDe.fromJson(jsonString, TableResult.class);
/* ... */
}
}
```# Why?
This package came about because I wanted to write tests for parts of applications that use
BQ TableResults, but didn't want to have to actually interact with BQ to run them. I'd hoped
that writing TableResults to JSON files (that I could read in and use on the next test runs) would be trivial.
When it wasn't, I wrote this helper library so it could be.# Notes
Please raise issues or make PRs if you have a question or spot a bug :heart::heart: