Dennis
Dennis

Reputation: 2142

Apache Hive: Convert Map<string,string> to a json string?

What is the easiest way in Apache Hive to convert a Map (String, String) to a string representation in json format?

I've tried reflect and the JSONValue class, but it seems that the reflect udf only accepts primitives datatypes...

Your help is highly appreciated.

Kind regards Dennis

Upvotes: 3

Views: 14721

Answers (1)

Jerome Banks
Jerome Banks

Reputation: 1630

Just use the "to_json" UDF from Brickhouse. ( http://github.com/klout/brickhouse ). It converts any arbitrary Hive structure into valid JSON. You can also parse arbitrary JSON formats into Hive structures with the "from_json" UDF.

Upvotes: 4

Related Questions