- json_t *result_array;
- json_t *record_obj;
-
- result_array = json_array();
- json_object = GNUNET_REST_jsonapi_object_new ();
- json_resource = GNUNET_REST_jsonapi_resource_new (GNUNET_REST_JSONAPI_GNS_TYPEINFO, handle->name);
- handle->lookup_request = NULL;
- for (i=0; i<rd_count; i++)
- {
- if ( (rd[i].record_type != handle->type) &&
- (GNUNET_GNSRECORD_TYPE_ANY != handle->type) )
- continue;
- record_obj = gnsrecord_to_json (&(rd[i]));
- json_array_append (result_array, record_obj);
- json_decref (record_obj);
- }
- GNUNET_REST_jsonapi_resource_add_attr (json_resource,
- GNUNET_REST_JSONAPI_GNS_RECORD,
- result_array);
- GNUNET_REST_jsonapi_object_resource_add (json_object, json_resource);
- GNUNET_REST_jsonapi_data_serialize (json_object, &result);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result);
- json_decref (result_array);
- GNUNET_REST_jsonapi_object_delete (json_object);
- resp = GNUNET_REST_create_json_response (result);
- handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
- GNUNET_free (result);
- cleanup_handle (handle);
-}