Recursively decodes values of entire dictionary (JSON) using base64.decodestring. Optionally ignores keys given in keys_to_skip. It’s also possible to give a custom decoder instead of base64.decodestring.
Recursively decodes values of entire dictionary (JSON) using base64.decodestring. Optionally ignores (does not include in the final dictionary) keys given in keys_to_skip.
NOTE: Whenever you can, give decoder callables, instead of strings (works faster).
NOTE: In HBase stargate $ keys represent values of the columns.
Parameters: |
|
---|---|
Return dict: | |
Example 1: |
>>> test_json_data = {
>>> u'Row': [
>>> {
>>> u'Cell': [
>>> {u'$': u'NDQ=', u'column': u'Y29tcG9uZW50Omlk', u'timestamp': 1369030584274},
>>> {u'$': u'MQ==', u'column': u'bWFjaGluZTppZA==', u'timestamp': 1369030584274},
>>> {u'$': u'NTUx', u'column': u'c2Vuc29yOmlk', u'timestamp': 1369030584274},
>>> {u'$': u'NjQ2', u'column': u'c2Vuc29yOm1lYXN1cmVtZW50', u'timestamp': 1369030584274},
>>> {u'$': u'VGVtcA==', u'column': u'c2Vuc29yOnR5cGU=', u'timestamp': 1369030584274},
>>> {u'$': u'UGFzY2Fs', u'column': u'c2Vuc29yOnVuaXRfb2ZfbWVhc3VyZQ==', u'timestamp': 1369030584274}
>>> ],
>>> u'key': u'NDk1MzczYzMtNGVkZi00OWZkLTgwM2YtMDljYjIxYTYyN2Vh'
>>> }
>>> ]
>>> }
>>> json_decode(test_json_data, keys_to_skip=['timestamp'])
], u’key’: ‘495373c3-4edf-49fd-803f-09cb21a627ea’
}
]
}
Example 2: |
---|
>>> # Assuming the `test_json_data` is the same as in example 1
>>> json_decode(test_json_data, decoder='path.to.your.own.decoder')
Example 3: |
---|
>>> # Assuming the `test_json_data` is the same as in example 1
>>> json_decode(test_json_data)
], u’key’: ‘495373c3-4edf-49fd-803f-09cb21a627ea’
}
]
}