/** * @file dockzen_launcher_json.c * @brief Generation of json data * Copyright (c) 2017 Samsung Electronics Co., Ltd. * This software is the confidential and proprietary information * of Samsung Electronics, Inc. ("Confidential Information"). You * shall not disclose such Confidential Information and shall use * it only in accordance with the terms of the license agreement * you entered into with Samsung. */ #include #include #include #include #include "dzl_internal_types.h" #include "dockzen_launcher_json.h" #include "json_util.h" char *makeUpdateJSON(char *imageName, char *containerName) { struct json_object *inputObj, *paramObj; char *ret_buf = NULL; const char *buf = NULL; inputObj = json_object_new_object(); paramObj = json_object_new_object(); json_object_object_add(paramObj, "ImageName", json_object_new_string(imageName)); json_object_object_add(paramObj, "ContainerName", json_object_new_string(containerName)); json_object_object_add(inputObj, "Cmd", json_object_new_string("UpdateImage")); json_object_object_add(inputObj, "UpdateParam", paramObj); buf = json_object_to_json_string_ext(inputObj, JSON_C_TO_STRING_SPACED | JSON_C_TO_STRING_PRETTY); ret_buf = (char*)malloc(strlen(buf)+1); if(ret_buf != NULL) { memset(ret_buf, 0x00, strlen(buf)+1); memcpy(ret_buf, buf, strlen(buf)); } json_object_put(inputObj); return ret_buf; }