rcongiu / Hive-JSON-Serde

Read - Write JSON SerDe for Apache Hive.
Other
733 stars 393 forks source link

Parsing escaped JSON from attributes #154

Closed d-robin closed 8 years ago

d-robin commented 8 years ago

Hello,

One of the JSON attributes contain escaped JSON data that is being treated as a string. Though it is an escaped JSON object, an array. Is there a way to deal with it using the library?

A simplified sample: {"Message": "[{\"Key\":\"GetService1\",\"ResponseTime\":\"12\"},{\"Key\":\"ServiceOperation\",\"ResponseTime\":\"2\"},{\"Key\":\"Service\",\"ResponseTime\":\"16\"}]" }

This is a case specific problem and not an issue. I've been looking up hard to deal with it. Any help or recommendation is greatly appreciated.

rcongiu commented 8 years ago

Eh, no , that is indeed a string and the serde has no way to know it's a JSON string. Have you tried extracting the json using get_json_object ?

d-robin commented 8 years ago

I tried that. It seems to expect well formed JSON object string too. :-/

d-robin commented 8 years ago

Hello Roberto, I finally solved it by converting the JSON string to Hive Array using regex transformations! Thanks :-)