Fixed reference to_json recursion bug.