|
3 | 3 | *
|
4 | 4 | * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
|
5 | 5 | * Michael Clark <[email protected]>
|
| 6 | + * Copyright (c) 2009 Hewlett-Packard Development Company, L.P. |
6 | 7 | *
|
7 | 8 | * This library is free software; you can redistribute it and/or modify
|
8 | 9 | * it under the terms of the MIT license. See COPYING for details.
|
@@ -172,10 +173,33 @@ extern void json_object_object_add(struct json_object* obj, const char *key,
|
172 | 173 | * @param obj the json_object instance
|
173 | 174 | * @param key the object field name
|
174 | 175 | * @returns the json_object associated with the given field name
|
| 176 | + * @deprecated Please use json_object_object_get_ex |
175 | 177 | */
|
176 | 178 | extern struct json_object* json_object_object_get(struct json_object* obj,
|
177 | 179 | const char *key);
|
178 | 180 |
|
| 181 | +/** Get the json_object associated with a given object field. |
| 182 | + * |
| 183 | + * This returns true if the key is found, false in all other cases (including |
| 184 | + * if obj isn't a json_type_object). |
| 185 | + * |
| 186 | + * *No* reference counts will be changed. There is no need to manually adjust |
| 187 | + * reference counts through the json_object_put/json_object_get methods unless |
| 188 | + * you need to have the child (value) reference maintain a different lifetime |
| 189 | + * than the owning parent (obj). Ownership of value is retained by obj. |
| 190 | + * |
| 191 | + * @param obj the json_object instance |
| 192 | + * @param key the object field name |
| 193 | + * @param value a pointer where to store a reference to the json_object |
| 194 | + * associated with the given field name. |
| 195 | + * |
| 196 | + * It is safe to pass a NULL value. |
| 197 | + * @returns whether or not the key exists |
| 198 | + */ |
| 199 | +extern json_bool json_object_object_get_ex(struct json_object* obj, |
| 200 | + const char *key, |
| 201 | + struct json_object **value); |
| 202 | + |
179 | 203 | /** Delete the given json_object field
|
180 | 204 | *
|
181 | 205 | * The reference count will be decremented for the deleted object. If there
|
|
0 commit comments