yo

Je ne comprends pas une erreur au niveau de ma fonction json.parse(). Cette fonction deserialise une query string pour la transformer en objet json. Apres des recherches dans la documentation et sur internet, je ne trouve pas de solution...

Mon erreur :
Nom : 119408nodeError.png
Affichages : 95
Taille : 9,3 Ko

L'argument de la fonction json.parse() est bien sous la forme requise. 'Unexpected token p' m'empeche d'aller plus loin, et je ne vois pas d'explication pour cela...

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
post_method:
    function () {
        var _this = this;
        var buff = "";
		console.log('post');
        this.req.on("data", function (c) {
            buff += c;
        });
        this.req.on("end", function () {
			_this.go_post(buff);
        });
    },
 
go_post:
    function (b) {
	var body = util.inspect(JSON.parse(b),false,null);
        this.res.writeHead(200, {"Content-Type": "application/json"});
        this.res.write(JSON.stringify({res: "ok"}));
        this.res.end();
    },
Pourriez-vous m'eclairer a ce sujet ?

Merci.