json-c

Looping code using PHP

…衆ロ難τιáo~ 提交于 2019-12-24 09:59:32
问题 I am currently using YouTube's API JSON-C response to pull data from a playlist and display the content in a list. I am doing this using PHP, however because YouTube restricts the maximum number of videos called, I have a hit a stumbling block. The maximum I can request is 50 whereas I have over 200 videos which I need to put in a list and I want to be able to do this dynamically. I understand that I will have to loop the response, which is what I have done but is there a way it can be

Memory Leak Using JSON-C

荒凉一梦 提交于 2019-12-21 09:31:50
问题 I am new to JSON-C, Please see my sample code and let me know of it will create any memory leak, if yes then how to free JSON-C object. struct json_object *new_obj = NULL; new_obj = json_tokener_parse(strRawJSON); new_obj = json_object_object_get(new_obj, "FUU"); if(NULL == new_obj){ SYS_OUT("\nFUU not found in JSON"); return NO; } new_obj = json_object_object_get(new_obj, "FOO"); // I m re-using new_obj, without free it? if(NULL == new_obj){ SYS_OUT("\nFOO not found in JSON"); return NO; } /

How to clean a json object created by “json_object_new_string”?

与世无争的帅哥 提交于 2019-12-04 03:58:30
问题 I have the following code and I want to clean a json object created by json_object_new_string() . #include <json/json.h> #include <stdio.h> int main() { /*Creating a json object*/ json_object * jobj = json_object_new_object(); /*Creating a json string*/ json_object *jstring = json_object_new_string("Joys of Programming"); /*Form the json object*/ json_object_object_add(jobj,"Site Name", jstring); /*Now printing the json object*/ printf ("The json object created: %sn",json_object_to_json

iOS Format String into minutes and seconds

a 夏天 提交于 2019-11-28 10:57:19
I am receiving a string from the YouTube JSONC api, but the duration is coming as a full number i.e 2321 instead of 23:21 or 2 instead of 0:02. How would I go about fixing this? JSON C EDIT: int duration = [videos valueForKey:@"duration"]; int minutes = duration / 60; int seconds = duration % 60; NSString *time = [NSString stringWithFormat:@"%d:%02d", minutes, seconds]; Assuming the duration value is really the duration in seconds, then you can calculate the number of minutes and seconds and then format those into a string. int duration = ... // some duration from the JSON int minutes =

iOS Format String into minutes and seconds

微笑、不失礼 提交于 2019-11-27 03:54:05
问题 I am receiving a string from the YouTube JSONC api, but the duration is coming as a full number i.e 2321 instead of 23:21 or 2 instead of 0:02. How would I go about fixing this? JSON C EDIT: int duration = [videos valueForKey:@"duration"]; int minutes = duration / 60; int seconds = duration % 60; NSString *time = [NSString stringWithFormat:@"%d:%02d", minutes, seconds]; 回答1: Assuming the duration value is really the duration in seconds, then you can calculate the number of minutes and seconds