gboolean mmsvc_core_msg_json_deserialize_len(char *key, char* buf, int *parse_len, void *data, mused_msg_parse_err_e *err) { int type; json_object *val, *jobj; g_return_val_if_fail(key != NULL, FALSE); g_return_val_if_fail(buf != NULL, FALSE); g_return_val_if_fail(data != NULL, FALSE); g_return_val_if_fail(parse_len != NULL, FALSE); jobj = _mmsvc_core_msg_json_tokener_parse_len(buf, parse_len, err); g_return_val_if_fail(jobj != NULL, FALSE); val = _mmsvc_core_msg_json_find_obj(jobj, key); if (!val) { LOGE("\"%s\" key is not founded", key); return FALSE; } type = json_object_get_type(val); switch (type) { case json_type_null: LOGD("json_type_null\n"); break; case json_type_boolean: LOGD("json_type_boolean (%s) value: %d", key, json_object_get_boolean(val)); break; case json_type_double: *(double *)data = json_object_get_double(val); LOGD("json_type_double (%s) value: %p", key, (double *)data); break; case json_type_int: *(int *)data = json_object_get_int(val); LOGD("json_type_int (%s) value: %p", key, (int *)data); break; case json_type_object: LOGD("json_type_object (%s) value: %d", key, json_object_get_object(val)); break; case json_type_string: strncpy((char *)data, json_object_get_string(val), strlen(json_object_get_string(val))); LOGD("json_type_string (%s) value: %s", key, (char *)data); break; case json_type_array: LOGD("json_type_array (%s)", key); int i, len; int *int_data = (int *)data; len = json_object_array_length(val); for (i = 0; i < len; i++) int_data[i] = json_object_get_int(json_object_array_get_idx(val, i)); break; } json_object_put(jobj); return TRUE; }
void json_parse(json_object * jobj) { enum json_type type; json_object_object_foreach(jobj, key, val) { type = json_object_get_type(val); switch (type) { case json_type_int: printf("type: json_type_int, "); printf("%s integer is %d\n" , key \ , json_object_get_int(val)); break; } }
json_object* OGRGeoJSONWriteFeature( OGRFeature* poFeature, int bWriteBBOX, int nCoordPrecision, int nSignificantFigures ) { CPLAssert( NULL != poFeature ); json_object* poObj = json_object_new_object(); CPLAssert( NULL != poObj ); json_object_object_add( poObj, "type", json_object_new_string("Feature") ); /* -------------------------------------------------------------------- */ /* Write native JSon data. */ /* -------------------------------------------------------------------- */ bool bIdAlreadyWritten = false; const char* pszNativeMediaType = poFeature->GetNativeMediaType(); json_object* poNativeGeom = NULL; if( pszNativeMediaType && EQUAL(pszNativeMediaType, "application/vnd.geo+json") ) { const char* pszNativeData = poFeature->GetNativeData(); json_object* poNativeJSon = NULL; if( pszNativeData && OGRJSonParse(pszNativeData, &poNativeJSon) && json_object_get_type(poNativeJSon) == json_type_object ) { json_object_iter it; it.key = NULL; it.val = NULL; it.entry = NULL; CPLString osNativeData; json_object_object_foreachC(poNativeJSon, it) { if( strcmp(it.key, "type") == 0 || strcmp(it.key, "properties") == 0 ) { continue; } if( strcmp(it.key, "bbox") == 0 ) { bWriteBBOX = true; continue; } if( strcmp(it.key, "geometry") == 0 ) { poNativeGeom = json_object_get(it.val); continue; } if( strcmp(it.key, "id") == 0 ) bIdAlreadyWritten = true; json_object_object_add( poObj, it.key, json_object_get(it.val) ); } json_object_put(poNativeJSon); } }
static pa_bool_t pa_json_is_fixed_type(json_object *o) { switch(json_object_get_type(o)) { case json_type_object: case json_type_array: return FALSE; default: return TRUE; } }
/// @TODO we should print all with this function static void print_monitor_value_enrichment(struct printbuf *buf, const json_object *const_enrichment) { json_object *enrichment = (json_object *)const_enrichment; for (struct json_object_iterator i = json_object_iter_begin(enrichment), end = json_object_iter_end(enrichment); !json_object_iter_equal(&i, &end); json_object_iter_next(&i)) { const char *key = json_object_iter_peek_name(&i); json_object *val = json_object_iter_peek_value(&i); const json_type type = json_object_get_type(val); switch (type) { case json_type_string: print_monitor_value_enrichment_str(buf, key, val); break; case json_type_int: print_monitor_value_enrichment_int(buf, key, val); break; case json_type_null: sprintbuf(buf, ",\"%s\":null", key); break; case json_type_boolean: { const json_bool b = json_object_get_boolean(val); sprintbuf(buf, ",\"%s\":%s", key, b == FALSE ? "false" : "true"); break; } case json_type_double: { const double d = json_object_get_double(val); sprintbuf(buf, ",\"%s\":%lf", key, d); break; } case json_type_object: case json_type_array: { rdlog(LOG_ERR, "Can't enrich with objects/array at this time"); break; } default: rdlog(LOG_ERR, "Don't know how to duplicate JSON type " "%d", type); break; }; } }
static void get_field_string(json_object *e, const char *path, char *dest, size_t n) { const char *str; json_object *node; node = json_object_object_get(e, path); if (node && (json_object_get_type(node) == json_type_string)) { str = json_object_get_string(node); strncpy(dest, str, n); } }
/** * Get the string length at a certain index * @param index * @return string */ size_t Array::strlen(int index) const { // get the value at this location json_object *value = json_object_array_get_idx(_json, index); // in case our type isn't string we return an empty string if (json_object_get_type(value) != json_type_string) return 0; // get the string length return json_object_get_string_len(value); }
/** * Get a string value at a certain index * @param index * @return string */ const char* Array::c_str(int index) const { // get the value at this location json_object *value = json_object_array_get_idx(_json, index); // in case our type isn't string we return an empty string if (json_object_get_type(value) != json_type_string) return ""; // cast to a char pointer return json_object_get_string(value); }
OGRLayer* OGRPLScenesDataV1Dataset::ParseItemType(json_object* poItemType) { if( poItemType == nullptr || json_object_get_type(poItemType) != json_type_object ) return nullptr; json_object* poId = CPL_json_object_object_get(poItemType, "id"); if( poId == nullptr || json_object_get_type(poId) != json_type_string ) return nullptr; CPLString osDisplayDescription; json_object* poDisplayDescription = CPL_json_object_object_get(poItemType, "display_description"); if( poDisplayDescription != nullptr && json_object_get_type(poDisplayDescription) == json_type_string ) osDisplayDescription = json_object_get_string(poDisplayDescription); CPLString osDisplayName; json_object* poDisplayName = CPL_json_object_object_get(poItemType, "display_name"); if( poDisplayName != nullptr && json_object_get_type(poDisplayName) == json_type_string ) osDisplayName = json_object_get_string(poDisplayName); const char* pszId = json_object_get_string(poId); // The layer might already exist if GetLayerByName() is called before // GetLayer()/GetLayerCount() is // Prevent GetLayerCount() from calling EstablishLayerList() bool bLayerListInitializedBackup = m_bLayerListInitialized; m_bLayerListInitialized = true; OGRLayer* poExistingLayer = GDALDataset::GetLayerByName(pszId); m_bLayerListInitialized = bLayerListInitializedBackup; if( poExistingLayer != nullptr ) return poExistingLayer; OGRPLScenesDataV1Layer* poPLLayer = new OGRPLScenesDataV1Layer( this, pszId); if( !osDisplayName.empty() ) poPLLayer->SetMetadataItem("SHORT_DESCRIPTION", osDisplayName.c_str()); if( !osDisplayDescription.empty() ) poPLLayer->SetMetadataItem("DESCRIPTION", osDisplayDescription.c_str()); m_papoLayers = (OGRPLScenesDataV1Layer**) CPLRealloc(m_papoLayers, sizeof(OGRPLScenesDataV1Layer*) * (m_nLayers + 1)); m_papoLayers[m_nLayers ++] = poPLLayer; return poPLLayer; }
/** * Add new key - null pair to json object. * @param osName Key name. * * @since GDAL 2.3 */ void CPLJSONObject::AddNull(const std::string &osName) { std::string objectName; CPLJSONObject object = GetObjectByPath( osName, objectName ); if( object.IsValid() && json_object_get_type(TO_JSONOBJ(object.m_poJsonObject)) == json_type_object ) { json_object_object_add( TO_JSONOBJ(object.GetInternalHandle()), objectName.c_str(), nullptr ); } }
static const char *dirserver_getJsonString(struct json_object *json, const char *field, const char *dflt) { struct json_object *json_tmp; json_tmp = json_object_object_get(json, field); if( json_tmp != NULL && !is_error(json_tmp) && json_object_get_type(json_tmp) == json_type_string ){ return json_object_get_string(json_tmp); } return dflt; }
static bool ParsePoint(json_object* poPoint, double* pdfX, double* pdfY) { if( poPoint != NULL && json_type_array == json_object_get_type(poPoint) && json_object_array_length(poPoint) == 2 ) { json_object* poX = json_object_array_get_idx(poPoint, 0); json_object* poY = json_object_array_get_idx(poPoint, 1); if( poX != NULL && (json_type_int == json_object_get_type(poX) || json_type_double == json_object_get_type(poX)) && poY != NULL && (json_type_int == json_object_get_type(poY) || json_type_double == json_object_get_type(poY)) ) { *pdfX = json_object_get_double(poX); *pdfY = json_object_get_double(poY); return true; } } return false; }
static int32_t dirserver_getJsonInt(struct json_object *json, const char *field, const int32_t dflt) { struct json_object *json_tmp; json_tmp = json_object_object_get(json, field); if( json_tmp != NULL && !is_error(json_tmp) && json_object_get_type(json_tmp) == json_type_int ){ return json_object_get_int(json_tmp); } return dflt; }
static gboolean dirserver_getJsonBool(struct json_object *json, const char *field, const gboolean dflt) { struct json_object *json_tmp; json_tmp = json_object_object_get(json, field); if( json_tmp != NULL && !is_error(json_tmp) && json_object_get_type(json_tmp) == json_type_boolean ){ return json_object_get_boolean(json_tmp)?TRUE:FALSE; } return dflt; }
OGRFieldType GeoJSONPropertyToFieldType( json_object* poObject ) { if (poObject == NULL) { return OFTString; } json_type type = json_object_get_type( poObject ); if( json_type_boolean == type ) return OFTInteger; else if( json_type_double == type ) return OFTReal; else if( json_type_int == type ) return OFTInteger; else if( json_type_string == type ) return OFTString; else if( json_type_array == type ) { int nSize = json_object_array_length(poObject); if (nSize == 0) return OFTStringList; /* we don't know, so let's assume it's a string list */ OGRFieldType eType = OFTIntegerList; for(int i=0;i<nSize;i++) { json_object* poRow = json_object_array_get_idx(poObject, i); if (poRow != NULL) { type = json_object_get_type( poRow ); if (type == json_type_string) return OFTStringList; else if (type == json_type_double) eType = OFTRealList; else if (type != json_type_int && type != json_type_boolean) return OFTString; } } return eType; } else return OFTString; /* null, object */ }
static void json_key_to_bson_key (bson *b, void *val, const gchar *key) { switch (json_object_get_type (val)) { case json_type_boolean: bson_append_boolean (b, key, json_object_get_boolean (val)); break; case json_type_double: bson_append_double (b, key, json_object_get_double (val)); break; case json_type_int: bson_append_int32 (b, key, json_object_get_int (val)); break; case json_type_string: bson_append_string (b, key, json_object_get_string (val), -1); break; case json_type_object: { bson *sub; sub = json_to_bson (val); bson_append_document (b, key, sub); bson_free (sub); break; } case json_type_array: { gint pos; bson *sub; sub = bson_new (); for (pos = 0; pos < json_object_array_length (val); pos++) { gchar *nk = g_strdup_printf ("%d", pos); json_key_to_bson_key (sub, json_object_array_get_idx (val, pos), nk); g_free (nk); } bson_finish (sub); bson_append_array (b, key, sub); bson_free (sub); break; } default: break; } }
void json_parse(json_object *jobj, struct elasticsearch_connection *conn) { enum json_type type; json_object *temp = NULL; json_object_object_foreach(jobj, key, val) { /* reinitialise to temp each iteration */ temp = NULL; type = json_object_get_type(val); /* the output of the json_parse varies per post type */ switch (conn->post_type) { case ELASTICSEARCH_POST_TYPE_LAST_UID: elasticsearch_connection_last_uid_json(conn, key, val); break; case ELASTICSEARCH_POST_TYPE_SELECT: elasticsearch_connection_select_json(conn, key, val); break; case ELASTICSEARCH_POST_TYPE_UPDATE: /* not implemented */ break; case ELASTICSEARCH_POST_TYPE_REFRESH: /* not implemented */ break; } /* recursively process the json */ switch (type) { case json_type_boolean: /* fall through */ case json_type_double: /* fall through */ case json_type_int: /* fall through */ case json_type_string: /* fall through */ break; case json_type_object: #if JSON_HAS_GET_EX json_object_object_get_ex(jobj, key, &temp); #else temp = json_object_object_get(jobj, key); #endif json_parse(temp, conn); break; case json_type_array: json_parse_array(jobj, key, conn); break; case json_type_null: break; } }
static int extract_severity_from_lines_object(json_object* lines) { int log_level = -1; if (lines != NULL && json_object_get_type(lines) == json_type_array) { int array_len = json_object_array_length(lines); for (int i=0; i<array_len; i++) { json_object *line = json_object_array_get_idx(lines, i); if (line && json_object_get_type(line) == json_type_array) { json_object *level = json_object_array_get_idx(line, 0); if (level) { int new_level = json_object_get_int(level); if (new_level > log_level) { log_level = new_level; } } } } } // protect against unknown log levels return (log_level > 5) ? -1 : log_level; }
/** * Add new key - value pair to json object. * @param osName Key name. * @param bValue Boolean value. * * @since GDAL 2.3 */ void CPLJSONObject::Add(const std::string &osName, bool bValue) { std::string objectName; CPLJSONObject object = GetObjectByPath( osName, objectName ); if( object.IsValid() && json_object_get_type(TO_JSONOBJ(object.m_poJsonObject)) == json_type_object ) { json_object *poVal = json_object_new_boolean( bValue ); json_object_object_add( TO_JSONOBJ(object.GetInternalHandle()), objectName.c_str(), poVal ); } }
/** * @ingroup VuoDispersion * Decodes the JSON object @c js to create a new value. */ VuoDispersion VuoDispersion_makeFromJson(json_object * js) { const char *valueAsString = ""; if (json_object_get_type(js) == json_type_string) valueAsString = json_object_get_string(js); VuoDispersion value = VuoDispersion_Linear; if (! strcmp(valueAsString, "radial")) value = VuoDispersion_Radial; return value; }
/** * @ingroup VuoVerticalAlignment * Decodes the JSON object @c js to create a new value. * * @eg{ * { * "replaceThis" : -1 * } * } */ VuoVerticalAlignment VuoVerticalAlignment_makeFromJson(json_object * js) { const char *valueAsString = ""; if (json_object_get_type(js) == json_type_string) valueAsString = json_object_get_string(js); if (strcmp(valueAsString, "center") == 0) return VuoVerticalAlignment_Center; else if (strcmp(valueAsString, "bottom") == 0) return VuoVerticalAlignment_Bottom; return VuoVerticalAlignment_Top; }
/** * @ingroup VuoDisplacement * Decodes the JSON object @c js to create a new value. */ VuoDisplacement VuoDisplacement_valueFromJson(json_object * js) { const char *valueAsString = ""; if (json_object_get_type(js) == json_type_string) valueAsString = json_object_get_string(js); VuoDisplacement value = VuoDisplacement_Transverse; if (! strcmp(valueAsString, "longitudinal")) value = VuoDisplacement_Longitudinal; return value; }
int jsonParseDouble(json_object *json_data, double *value) { if (value == NULL || json_data == NULL) { return 1; } enum json_type type = json_object_get_type(json_data); if (type != json_type_double) { *value = 0; return 1; } *value = json_object_get_double(json_data); return 0; }
/** * Decodes the JSON object @c js to create a new value. * * @eg{ * "end" * } */ VuoListPosition VuoListPosition_makeFromJson(json_object * js) { const char *valueAsString = ""; if (json_object_get_type(js) == json_type_string) valueAsString = json_object_get_string(js); VuoListPosition value = VuoListPosition_Beginning; if (strcmp(valueAsString, "end") == 0) value = VuoListPosition_End; return value; }
static kpfs_ret kpfs_conf_parse_json(const char *buf) { json_object *jobj = NULL; if (!buf) return KPFS_RET_FAIL; jobj = json_tokener_parse(buf); if (!jobj || is_error(jobj)) return KPFS_RET_FAIL; memset(&g_kpfs_conf, 0, sizeof(g_kpfs_conf)); json_object_object_foreach(jobj, key, val) { if (!strcmp(key, KPFS_CONF_ID_CONSUMER_KEY)) { if (json_type_string == json_object_get_type(val)) snprintf(g_kpfs_conf.consumer_key, sizeof(g_kpfs_conf.consumer_key), "%s", json_object_get_string(val)); } else if (!strcmp(key, KPFS_CONF_ID_CONSUMER_SECRET)) { if (json_type_string == json_object_get_type(val)) snprintf(g_kpfs_conf.consumer_secret, sizeof(g_kpfs_conf.consumer_secret), "%s", json_object_get_string(val)); } else if (!strcmp(key, KPFS_CONF_ID_ROOT)) { if (json_type_string == json_object_get_type(val)) { snprintf(g_kpfs_conf.root, sizeof(g_kpfs_conf.root), "%s", json_object_get_string(val)); if (0 != strcmp(KPFS_API_ROOT_KUAIPAN, g_kpfs_conf.root) && 0 != strcmp(KPFS_API_ROOT_APP_FOLDER, g_kpfs_conf.root)) { snprintf(g_kpfs_conf.root, sizeof(g_kpfs_conf.root), "%s", KPFS_API_ROOT_KUAIPAN); } } } else if (!strcmp(key, KPFS_CONF_ID_MOUNT_POINT)) { if (json_type_string == json_object_get_type(val)) snprintf(g_kpfs_conf.mount_point, sizeof(g_kpfs_conf.mount_point), "%s", json_object_get_string(val)); } else if (!strcmp(key, KPFS_CONF_ID_OAUTH_JSON_FILE)) { if (json_type_string == json_object_get_type(val)) snprintf(g_kpfs_conf.oauth_json_file, sizeof(g_kpfs_conf.oauth_json_file), "%s", json_object_get_string(val)); } else if (!strcmp(key, KPFS_CONF_ID_WRITABLE_TMP_PATH)) { if (json_type_string == json_object_get_type(val)) snprintf(g_kpfs_conf.writable_tmp_path, sizeof(g_kpfs_conf.writable_tmp_path), "%s", json_object_get_string(val)); } } json_object_put(jobj); if (g_kpfs_conf.mount_point[0] == '\0') { return KPFS_RET_FAIL; } if (g_kpfs_conf.consumer_key[0] == '\0') snprintf(g_kpfs_conf.consumer_key, sizeof(g_kpfs_conf.consumer_key), "%s", KPFS_CONSUMER_KEY); if (g_kpfs_conf.consumer_secret[0] == '\0') snprintf(g_kpfs_conf.consumer_secret, sizeof(g_kpfs_conf.consumer_secret), "%s", KPFS_CONSUMER_SECRET); if (g_kpfs_conf.root[0] == '\0') snprintf(g_kpfs_conf.root, sizeof(g_kpfs_conf.root), "%s", KPFS_API_ROOT_KUAIPAN); if (g_kpfs_conf.oauth_json_file[0] == '\0') snprintf(g_kpfs_conf.oauth_json_file, sizeof(g_kpfs_conf.oauth_json_file), "%s", KPFS_DEFAULT_OAUTH_JSON_FILE); if (g_kpfs_conf.writable_tmp_path[0] == '\0') snprintf(g_kpfs_conf.writable_tmp_path, sizeof(g_kpfs_conf.writable_tmp_path), "%s", KPFS_DEFAULT_WRITABLE_TMP_PATH); return KPFS_RET_OK; }
json_object* OGRAMIGOCLOUDGetSingleRow(json_object* poObj) { if( poObj == NULL ) { return NULL; } json_object* poRows = CPL_json_object_object_get(poObj, "data"); if( poRows == NULL || json_object_get_type(poRows) != json_type_array || json_object_array_length(poRows) != 1 ) { return NULL; } json_object* poRowObj = json_object_array_get_idx(poRows, 0); if( poRowObj == NULL || json_object_get_type(poRowObj) != json_type_object ) { return NULL; } return poRowObj; }
json_object_object_foreach(jobj, key, val) { char *value; size_t value_len = 0; int array_len; enum json_type inner_type = json_object_get_type(val); switch (inner_type) { case json_type_boolean: kvp_add((struct _kvp_store *)jenc, key, kvp_val_create(NULL, json_object_get_boolean(val) ? 1 : 0), 0); break; case json_type_double: kvp_add((struct _kvp_store *)jenc, key, kvp_val_create(NULL, json_object_get_double(val)), 0); break; case json_type_int: kvp_add((struct _kvp_store *)jenc, key, kvp_val_create(NULL, json_object_get_int(val)), 0); break; case json_type_string: value = string_create(&value_len, snprintf(NULL, 0, "%s", json_object_get_string(val))); sprintf(value, "%s", json_object_get_string(val)); kvp_add((struct _kvp_store *)jenc, key, kvp_val_create(value, 0), 0); string_free(value, &value_len); break; case json_type_object: value = string_create(&value_len, snprintf(NULL, 0, "%s", json_object_get_string(val))); sprintf(value, "%s", json_object_get_string(val)); kvp_add((struct _kvp_store *)jenc, key, kvp_val_create(value, 0), 0); string_free(value, &value_len); json_object_put(val); break; case json_type_array: array_len = json_object_array_length(val); for (int i = 0; i < array_len; i++) { json_object *array_member = json_object_array_get_idx(val, i); if (!is_error(array_member)) { value = string_create(&value_len, snprintf(NULL, 0, "%s", json_object_get_string(array_member))); sprintf(value, "%s", json_object_get_string(array_member)); kvp_add((struct _kvp_store *)jenc, key, kvp_val_create(value, 0), 0); string_free(value, &value_len); } } break; case json_type_null: kvp_add((struct _kvp_store *)jenc, key, kvp_val_create("", 0), 0); break; } }
int ucloud_uhost_create(ucloud_http_params_t *param, char **host_ids, int *num) { if (param == NULL) { return UCLOUDE_INVALID_PARAM; } ucloud_http_params_add(param, "Action", "CreateUHostInstance"); //do request ucloud_uhttp_response_t *resp; resp = ucloud_uhttp_response_init(); int ret = ucloud_uhttp_request(param, resp); if (ret != UCLOUDE_OK) { goto error; } //handle response json_object *jobj = json_tokener_parse(resp->result); if (ucloud_uhttp_handle_resp_header(jobj) != 0) { goto error; } json_object *jval; if (json_object_object_get_ex(jobj, "UHostIds", &jval) && json_object_get_type(jval) == json_type_array) { int i = 0; int count = json_object_array_length(jval); if (count > *num) { *num = count; ucloud_uhttp_response_deinit(resp); return UCLOUDE_INSUFF_LENGTH; } *num = count; for (i= 0; i<count; ++i) { json_object *jitem = json_object_array_get_idx(jval, i); strcpy(host_ids[i], json_object_get_string(jitem)); } } ucloud_uhttp_response_deinit(resp); return UCLOUDE_OK; error: ucloud_uhttp_response_deinit(resp); return UCLOUDE_ERROR; }
static void mq_blynk_js_cb(struct json_object *js, void *priv) { OutputMap *map = (OutputMap*)priv; switch (json_object_get_type(js)) { case json_type_double: map->blynk->virtualWrite(map->pin, json_object_get_double(js)); break; case json_type_int: map->blynk->virtualWrite(map->pin, json_object_get_int(js)); break; default: break; } }
static LWGEOM* parse_geojson_polygon(json_object *geojson, bool *hasz, int *root_srid) { LWGEOM *geom; POINTARRAY **ppa; json_object* rings = NULL; int i = 0, j = 0; int ring = 0; rings = findMemberByName( geojson, "coordinates" ); if ( ! rings ) geojson_lwerror("Unable to find 'coordinates' in GeoJSON string", 4); ppa = (POINTARRAY**) lwalloc(sizeof(POINTARRAY*)); if( json_type_array == json_object_get_type( rings ) ) { int nPoints; json_object* points = NULL; ppa[0] = ptarray_construct_empty(1, 0, 1); ring = json_object_array_length( rings ); points = json_object_array_get_idx( rings, 0 ); nPoints = json_object_array_length( points ); for (i=0; i < nPoints; i++ ) { json_object* coords = NULL; coords = json_object_array_get_idx( points, i ); parse_geojson_coord(coords, hasz, ppa[0]); } for(i = 1; i < ring; ++i) { int nPoints; ppa = (POINTARRAY**) lwrealloc((POINTARRAY *) ppa, sizeof(POINTARRAY*) * (i + 1)); ppa[i] = ptarray_construct_empty(1, 0, 1); points = json_object_array_get_idx( rings, i ); nPoints = json_object_array_length( points ); for (j=0; j < nPoints; j++ ) { json_object* coords = NULL; coords = json_object_array_get_idx( points, j ); parse_geojson_coord(coords, hasz, ppa[i]); } } } geom = (LWGEOM *) lwpoly_construct(*root_srid, NULL, ring, ppa); return geom; }