Reputation: 3
I've read in JSON from a source REST endpoint and am writing out to BigQuery table. I want to make the BigQuery table attributes more readable ie. From src_lat to source_latitude etc...
I have managed to create a TableSchema definition which fits purpose, my question is how do I map the TableRow definition from the source to the new target attributes?
Upvotes: 0
Views: 97
Reputation: 76799
see JsonFactory.parse()
in combination with https://developers.google.com/api-client-library/java/google-http-java-client/reference/1.20.0/com/google/api/client/json/CustomizeJsonParser ...this permits customizing the parser, in order to parse into a destination class of objects, which has different field names. you'll have to extend CustomizeJsonParser
and implement the method handleUnrecognizedKey
, which is being called for all the field keys, which cannot be mapped directly and then re-map those fields properly, eg. in a switch
statement.
one can also use the Jackson Streaming API to re-map the fields, see this example.
Upvotes: 1