Making necessary C changes to only call to_json if it is present