Re: json-glib problem
- From: Emmanuele Bassi <ebassi gmail com>
- To: Aldrich Niklaus <aldrichnjit gmail com>
- Cc: "gnome-devel-list gnome org" <gnome-devel-list gnome org>
- Subject: Re: json-glib problem
- Date: Thu, 23 May 2013 08:48:05 +0100
hi;
On 23 May 2013 08:40, Aldrich Niklaus <aldrichnjit gmail com> wrote:
I want to us json-glib to parse a json file ,and I wrote a demo like this.
int main(int argc,char **argv)
{
JsonParser *parser;
GError *error;
g_type_init();
if you're using a recent version of GLib, calling g_type_init() is not
strictly necessary.
JsonNode *root;
root = json_parser_get_root(parser);
if you're walking through a JSON tree, then you can also use
JsonReader: its API should be slightly easier to use.
and the info.json file is here.
[{"tinyurl":"http://hdn.xnimg.cn/photos/hdn121/20121221/2320/tiny_9gJc_310d000027911375.jpg","sex":1,"university_history":[{"department":"others","name":"University
of Alaska
Fairbanks","year":2008}],"work_history":[],"star":0,"mainurl":"http://hdn.xnimg.cn/photos/hdn521/20121221/2320/h_main_Rka5_5af7000023451376.jpg","headurl":"http://hdn.xnimg.cn/photos/hdn521/20121221/2320/h_head_uFt9_5af7000023451376.jpg","vip":4,"hometown_location":{"province":"黑龙江","city":"shuangyashang"},"name":"xiaolongfeng","email_hash":"","zidou":1}]
but when I compile the demo,I got a segment fault,I do not know what`s wrong with my demo program.
you should look at the stack trace of the segmentation fault by
running your program under gdb; just use:
gdb --args ./your-demo-program
and type "bt" when the program aborts.
you'll see where the program crashes and hopefully why. in case, copy
the stack trace in a reply.
ciao,
Emmanuele.
--
W: http://www.emmanuelebassi.name
B: http://blogs.gnome.org/ebassi/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]