diff --git a/_100-days-of-code/2018-01-01-100-days-of-code-day011.markdown b/_100-days-of-code/2018-01-01-100-days-of-code-day011.markdown new file mode 100644 index 0000000..1a4e316 --- /dev/null +++ b/_100-days-of-code/2018-01-01-100-days-of-code-day011.markdown @@ -0,0 +1,34 @@ +--- +layout: post +title: "day 11" +date: 2018-01-17 +categories: programming +--- + +# 100 Days of Code + +### Day 11: +Took a break on the weekend, but I am back at it. Today, I made a class for +decoding json data. Here is the code. I can use this with my xonsh shell now so +its proving to be useful. + +```python + +import os +import json +from pprint import pprint + +class JsonUtils(object): + """ Json utility library """ + + + def decode(self, json_file): + """ Decode a json string or file that contains json """ + if os.path.isfile(json_file): + with open(json_file, 'r'): + data = json.load(json_file) + return pprint(data) + else: + data = json.loads(json_file) + return pprint(data) +```