Fix json export

Fix exported json and add testcase for that.