fixed as_json for output of joins, thanks Alan