You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pn...@apache.org on 2015/11/05 16:42:05 UTC

[3/3] celix git commit: CELIX-273: Fixed an issue concerning json string deserialization.

CELIX-273: Fixed an issue concerning json string deserialization.


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/fbc4dea3
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/fbc4dea3
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/fbc4dea3

Branch: refs/heads/develop
Commit: fbc4dea3e10087b16bda236431f5ee0400b36615
Parents: e1be5f1
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Thu Nov 5 16:41:19 2015 +0100
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Thu Nov 5 16:41:19 2015 +0100

----------------------------------------------------------------------
 .../json_serializer.c                           | 24 ++++++++++++++------
 1 file changed, 17 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/fbc4dea3/remote_services/remote_service_admin_dfi/dynamic_function_interface/json_serializer.c
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin_dfi/dynamic_function_interface/json_serializer.c b/remote_services/remote_service_admin_dfi/dynamic_function_interface/json_serializer.c
index 942d520..8d42bb4 100644
--- a/remote_services/remote_service_admin_dfi/dynamic_function_interface/json_serializer.c
+++ b/remote_services/remote_service_admin_dfi/dynamic_function_interface/json_serializer.c
@@ -67,19 +67,29 @@ int jsonSerializer_deserializeJson(dyn_type *type, json_t *input, void **out) {
 static int jsonSerializer_createType(dyn_type *type, json_t *val, void **result) {
     assert(val != NULL);
     int status = OK;
-
     void *inst = NULL;
-    status = dynType_alloc(type, &inst);
 
-    if (status == OK) {
-        assert(inst != NULL);
-        status = jsonSerializer_parseAny(type, inst, val);
+    if (dynType_descriptorType(type) == 't') {
+        if (json_typeof(val) == JSON_STRING) {
+            inst = strdup(json_string_value(val));
+        } else {
+            status = ERROR;
+            LOG_ERROR("Expected json_string type got %i\n", json_typeof(val));
+        }
+    } else {
+        status = dynType_alloc(type, &inst);
 
-        if (status != OK) {
-            dynType_free(type, inst);
+        if (status == OK) {
+            assert(inst != NULL);
+            status = jsonSerializer_parseAny(type, inst, val);
+
+            if (status != OK) {
+                dynType_free(type, inst);
+            }
         }
     }
 
+
     if (status == OK) {
         *result = inst;
     }