Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- JsonNode* json_node_get (JsonNode* node, GValue* value) {
- g_return_val_if_fail (node != NULL, NULL);
- g_return_val_if_fail (val != NULL, NULL);
- GType type = G_VALUE_TYPE (val);
- JsonNode* result = NULL;
- JsonNodeType jtype = json_node_get_node_type (node);
- if (jtype == JSON_NODE_OBJECT && type == G_TYPE_STRING) {
- const gchar* key = g_value_get_string (value);
- JsonObject* object = json_node_get_object (node);
- result = json_object_get_member (object, key);
- }
- if (jtype == JSON_NODE_ARRAY && (type == G_TYPE_INT || type == G_TYPE_UINT)) {
- guint index = 0;
- if (type == G_TYPE_INT)
- index = (guint)g_value_get_int (value);
- else
- index = g_value_get_uint (value);
- JsonArray* array = json_node_get_array (node);
- result = json_array_get_element (array, index);
- }
- return NULL;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement