Closed korayal closed 1 year ago
When a field has type Maybe [a] where a is not a Text, the ToJSON or FromJSON instances fail trying to parse the result.
Maybe [a]
a
Text
destinationUriFileCounts is a good example.
destinationUriFileCounts
When trying to read the result of a BigQuery extraction job, the request fails trying to parse the response with below error:
Error in $.statistics.extract.destinationUriFileCounts[0]: parsing Int64 failed, expected Number, but encountered String
With this update, below diff is applied to this snippet
--- a/tmp/left.hs +++ b/tmp/right.hs @@ -23,7 +23,9 @@ instance Core.FromJSON JobStatistics4 where "JobStatistics4" ( \o -> JobStatistics4 - Core.<$> (o Core..:? "destinationUriFileCounts") + Core.<$> ( o Core..:? "destinationUriFileCounts" + Core.<&> Core.fmap (Core.fmap Core.fromAsText) + ) Core.<*> ( o Core..:? "inputBytes" Core.<&> Core.fmap Core.fromAsText ) @@ -34,6 +36,7 @@ instance Core.ToJSON JobStatistics4 where Core.object ( Core.catMaybes [ ("destinationUriFileCounts" Core..=) + Core.. Core.fmap Core.AsText Core.<$> destinationUriFileCounts, ("inputBytes" Core..=) Core.. Core.AsText Core.<$> inputBytes
When a field has type
Maybe [a]
wherea
is not aText
, the ToJSON or FromJSON instances fail trying to parse the result.destinationUriFileCounts
is a good example.When trying to read the result of a BigQuery extraction job, the request fails trying to parse the response with below error:
With this update, below diff is applied to this snippet