Open danwdart opened 5 years ago
Same for me.
I found the root cause:
The response JSON seems to have an extra "data" tag:
body = {"q":["Dursleys were proud to say that they were perfectly normal."],"source":"en","target":"es"}
}
[Client Response] {
status = 200 OK
headers = content-type: application/json; charset=UTF-8; vary: Origin; vary: X-Origin; vary: Referer; content-encoding: gzip; date: Tue, 27 Aug 2019 22:38:59 GMT; server: ESF; cache-control: private; x-xss-protection: 0; x-frame-options: SAMEORIGIN; x-content-type-options: nosniff; alt-svc: quic=":443"; ma=2592000; v="46,43,39"; transfer-encoding: chunked
}
Object (fromList [("data",Object (fromList [("translations",Array [Object (fromList [("translatedText",String "Los Dursley estaban orgullosos de decir que eran perfectamente normales.")])])]))])
I made a monkey patch in the gogol-translate:
instance FromJSON TranslationsListResponse where
parseJSON =
withObject "" (\o1 -> do
x <- o1 .: "data"
withObject "" (\o ->
TranslationsListResponse' <$>
(o .:? "translations" .!= mempty)
)
x)
@brendanhay What is the best way to actually implement this fix in the gogol framework? I am happy to do the legwork, but I need some guidance.
I've got a translate request with trace:
however it doesn't actually save anything into the variable:
TranslationsListResponse' {_tlrTranslations = Nothing}
Credentials are all good, I tried in wget and browser console and it was fine and returned proper response, but using this is just a response of Nothing...
Code:
Thanks