Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. struct json_object *new_obj = NULL;
  2. new_obj = json_tokener_parse(strRawJSON);
  3. new_obj = json_object_object_get(new_obj, "FUU");
  4. if(NULL == new_obj){
  5. SYS_OUT("nFUU not found in JSON");
  6. return NO;
  7. }
  8. new_obj = json_object_object_get(new_obj, "FOO"); // I m re-using new_obj, without free it?
  9. if(NULL == new_obj){
  10. SYS_OUT("nFOO not found in JSON");
  11. return NO;
  12. }
  13. // DO I need to clean new_obj, if yes then how ??
  14.  
  15. struct json_object *new_obj, *fuu_obj, *foo_obj;
  16. new_obj = json_tokener_parse(strRawJSON);
  17. fuu_obj = json_object_object_get(new_obj, "FUU");
  18. if(NULL == new_obj){
  19. SYS_OUT("nFUU not found in JSON");
  20. return NO;
  21. }
  22. foo_obj = json_object_object_get(new_obj, "FOO");
  23. if(NULL == new_obj){
  24. SYS_OUT("nFOO not found in JSON");
  25. return NO;
  26. }
  27. json_object_put(foo_obj);
  28. json_object_put(fuu_obj);
  29. json_object_put(new_obj);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement