- json_decref()
釋放創(chuàng)建的object的引用,一些獲取json_object返回的是new reference
需要手動(dòng)進(jìn)行釋放:
json_t *json_object(void)?
Return value: New reference.
Returns a new JSON object, or NULL on error. Initially, the object is empty.
但是有些函數(shù)返回的時(shí)候borrow reference
:
json_t *json_object_get(const json_t *object, const char *key)?
Return value: Borrowed reference.
Get a value corresponding to key from object. Returns NULL if key is not found and on error.
這是沒有計(jì)入引用的使用,最好手動(dòng)去json_incref(),然后手動(dòng)json_decref()釋放