avoid to use a specific provider field
[psensor.git] / src / lib / psensor_json.c
index b6feecf..058a25e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010-2013 jeanfi@gmail.com
+ * Copyright (C) 2010-2014 jeanfi@gmail.com
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -19,6 +19,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <stdio.h>
+
 #include "psensor_json.h"
 #include "url.h"
 
@@ -140,9 +142,9 @@ struct psensor *psensor_new_from_json(json_object *o,
        struct psensor *s;
        char *eid, *url;
 
-       oid = json_object_object_get(o, "id");
-       oname = json_object_object_get(o, "name");
-       otype = json_object_object_get(o, "type");
+       json_object_object_get_ex(o, "id", &oid);
+       json_object_object_get_ex(o, "name", &oname);
+       json_object_object_get_ex(o, "type", &otype);
 
        eid = url_encode(json_object_get_string(oid));
        url = malloc(strlen(sensors_url) + 1 + strlen(eid) + 1);
@@ -153,7 +155,7 @@ struct psensor *psensor_new_from_json(json_object *o,
                           NULL,
                           json_object_get_int(otype) | SENSOR_TYPE_REMOTE,
                           values_max_length);
-       s->url = url;
+       s->provider_data = url;
 
        free(eid);