Skip to content

Instantly share code, notes, and snippets.

@jeromebanks
Created February 7, 2014 00:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeromebanks/8855457 to your computer and use it in GitHub Desktop.
Save jeromebanks/8855457 to your computer and use it in GitHub Desktop.
to_json with named_struct
select
to_json( named_struct("key1", 0, "key2", "a string val", "key3", array( 4,5,6), "key4", map("a",2.3,"b",5.6) ))
from mytable;
Output is
' { "key1":0, "key2":"a string val", "key3":[4,5,6], "key4":{"a":2.3, "b":5.6} } '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment