nitin1 15 Master Poster

{"title":"iamtitle","icon":"","urlHistory":["http://google.com"],"lastUsed":123}

I have tried in c++ and using json-glib. I have tried using this:

                g_type_init();

                JsonParser *parser = json_parser_new();
                json_parser_load_from_data(parser, temp.c_str(), -1, NULL);

                JsonReader *reader = json_reader_new(json_parser_get_root(parser));

                json_reader_read_member(reader,"urlHistory");
                JsonNode * value = json_reader_get_value(reader);
                JsonArray * value1 = json_node_get_array(value);
                const char * urlhistory = json_array_get_string_element(value1,0);
                tab.history = urlhistory;
                json_reader_end_element(reader);
                cout << endl << "correct URL-->: " << tab.history << endl;

                json_reader_read_member(reader, "title");
                const char * title = json_reader_get_string_value(reader);
                json_reader_end_member(reader);
                tab.title = string(title);

                json_reader_read_member(reader, "lastUsed");
                int lastUsed = json_reader_get_int_value(reader);
                json_reader_end_member(reader);

                tab.lastUsed = lastUsed * 1000L;

                json_reader_read_member(reader, "icon");
                gboolean checker = json_reader_get_null_value(reader);
                const char * icon = "";

                if (!checker) {
                    cout << "I am not null in icon tabs" << endl;
                    icon = json_reader_get_string_value(reader);
                    tab.icon = icon;
                    json_reader_end_member(reader);
                } else {
                    cout << "I am in icon null" << endl;
                    tab.icon = "";
                    json_reader_end_member(reader);
                }

                g_object_unref(reader);
                g_object_unref(parser);

It is giving error whiel reading urlhistory. Please tell why it is. I am able to get the nomrla string values but don't know how I can take values like arrays from json like this. Please tell. Thanks.