ported from python2 to python3, changed from ast to json