Support Questions
Find answers, ask questions, and share your expertise

get human readable JSON from the HBase rest service

Rising Star

HBase has a convenient REST service, e.g. if we create some records in an HBase table:

$ hbase shell
hbase(main):001:0> create 'profile', 'demographics'
hbase(main):002:0> put 'profile', 1234, 'demographics:age', 42
hbase(main):003:0> put 'profile', 1234, 'demographics:gender', 'F'
hbase(main):004:0> put 'profile', 2345, 'demographics:age', 8
hbase(main):005:0> put 'profile', 2345, 'demographics:gender', 'M'

hbase(main):006:0> scan 'profile'
ROW     COLUMN+CELL
1234    column=demographics:age, timestamp=1496754873362, value=42
1234    column=demographics:gender, timestamp=1496754880025, value=F
2345    column=demographics:age, timestamp=1496754886334, value=8
2345    column=demographics:gender, timestamp=1496754891898, value=M

... and start the HBase REST service:

[root@hdp03 ~]# hbase rest start

We can retrieve the values by making calls to the HBase REST service:

$ curl 'http://hdp03.woolford.io:8080/profile/1234' -H "Accept: application/json"
{
	"Row": [{
		"key": "MTIzNA==",
		"Cell": [{
			"column": "ZGVtb2dyYXBoaWNzOmFnZQ==",
			"timestamp": 1496754873362,
			"$": "NDI="
		}, {
			"column": "ZGVtb2dyYXBoaWNzOmdlbmRlcg==",
			"timestamp": 1496754880025,
			"$": "Rg=="
		}]
	}]
}

I notice that the HBase column names and cell values returned by the HBase REST service are base64 encoded:

$ python
>>> import base64
>>> base64.b64decode("MTIzNA==")
'1234'
>>> base64.b64decode("ZGVtb2dyYXBoaWNzOmFnZQ==")
'demographics:age'
>>> base64.b64decode("NDI=")
'42'
>>> base64.b64decode("ZGVtb2dyYXBoaWNzOmdlbmRlcg==")
'demographics:gender'
>>> base64.b64decode("Rg==")
'F'

That's great for machine-to-machine communication, e.g. a webservice, but isn't very user-friendly since base64 isn't human readable. Is there a simple way (e.g. header parameter, HBase property) to make the HBase REST service return human-readable JSON? I realize I could write my own service, but I'd rather re-use existing code/functionality if possible.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: get human readable JSON from the HBase rest service

No, there is presently no option to do what you're asking. HBase stores arbitrary bytes which means that data in any portion of the response object may generate invalid JSON.

If you do chose to write some software to solve your issue, I would guess that the Apache HBase community would be accepting of some option/configuration that does add what you're asking for to the REST server.

View solution in original post

1 REPLY 1

Re: get human readable JSON from the HBase rest service

No, there is presently no option to do what you're asking. HBase stores arbitrary bytes which means that data in any portion of the response object may generate invalid JSON.

If you do chose to write some software to solve your issue, I would guess that the Apache HBase community would be accepting of some option/configuration that does add what you're asking for to the REST server.

View solution in original post