use strndup to support older json-c without json_object_new_string_len