added safejson function