bonjour a tous,

je souhaite parser un fichier json que je récupère en interrogent un web service.
j'ai trouvé pour cela un librairie qui permet de faire cela avec une manière super facile, elle s'appelle GSON voici le lien: http://code.google.com/p/google-gson/.

le souci c'est que quand j'importe la librairie, elle ne reconnait pas la classe GSON.

voici mon code:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
public class ParserJson {
 
    String json = 
        "{"
            + "'title': 'Computing and Information systems',"
            + "'id' : 1,"
            + "'children' : 'true',"
            + "'groups' : [{"
                + "'title' : 'Level one CIS',"
                + "'id' : 2,"
                + "'children' : 'true',"
                + "'groups' : [{"
                    + "'title' : 'Intro To Computing and Internet',"
                    + "'id' : 3,"
                    + "'children': 'false',"
                    + "'groups':[]"
                + "}]" 
            + "}]"
        + "}";
 
    // Now do the magic.
    Data data = new Gson().fromJson(json, Data.class);
 
    // Show it.
    //System.out.println(data);
}
 
 
 
class Data {
	private String title;
	private Long id;
	private Boolean children;
	private List<Data> groups;
 
	public String getTitle() { return title; }
	public Long getId() { return id; }
	public Boolean getChildren() { return children; }
	public List<Data> getGroups() { return groups; }
 
	public void setTitle(String title) { this.title = title; }
	public void setId(Long id) { this.id = id; }
	public void setChildren(Boolean children) { this.children = children; }
	public void setGroups(List<Data> groups) { this.groups = groups; }
 
	public String toString() {
		return String.format("title:%s,id:%d,children:%s,groups:%s", title, id, children, groups);
}
si quelqu'un peut m'aider s'il vous plait, ou si vous connaissez d'autre librairie.

merci d'avance.