Add a from_json() function. Fix #168.

Close #169.