0

I have a list of JSON's which need to be read and inserted as JSON objects into HBase. Each JSON (could be a nested JSON) needs to be read from the list and inserted along with a new row key

put (key, <json>)

Format:

[ 
  {
    "x":"x-val",
    "y":222,
    "z":{
          "m":"m-val",
          "n":"n-val"
        }
  },
  {
     ..
  }
]
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
voidone
  • 333
  • 1
  • 3
  • 12
  • If you have Hive available, you could use that to help you. https://stackoverflow.com/questions/28350258/insert-data-into-hbase-using-hive-json-file – OneCricketeer Feb 09 '16 at 04:45
  • I've tried happybase API and I can't use Hive .. Can I convert the JSON to a blob and insert into hbase? – voidone Feb 09 '16 at 05:04
  • Do you know how to use `json.loads()` in Python and have you reading [storing data](https://happybase.readthedocs.org/en/latest/user.html#storing-data) with Happybase? Please include the Python code you have tried in your question – OneCricketeer Feb 09 '16 at 05:06

1 Answers1

0

You can use json.dumps(dict) to convert a dictionary to a JSON string.

json_data = [json.dumps(x) for x in list_of_data]

I recommend happybase to connect to HBase and store the JSON, as shown here. You can either loop over the json_data and do multiple puts, or explore happybase's batch functionality.

Def_Os
  • 5,301
  • 5
  • 34
  • 63