For following code:-
var str = JSON.parse(new Buffer(req.body.profile, 'base64').toString());
var UserDeserialize = new JSONAPIDeserializer();
var obj = UserDeserialize.deserialize(str).then(result => {
console.log(result);
If i am using entering user input like:-
**
POST / HTTP/1.1
Host: localhost:1337
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Firefox/52.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: close
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
Content-Length: 72
profile=eyAiZGF0YSI6IFsgeyAidHlwZSI6ICJpZHMiLCAiaWQiOiJ0ZXN0IiB9IF0gfQ==
**
Where profile=eyAiZGF0YSI6IFsgeyAidHlwZSI6ICJpZHMiLCAiaWQiOiJ0ZXN0IiB9IF0gfQ==
is
{ "data": [ { "type": "ids", "id":"test" } ] }`
But if I am trying to pass serialized function like this way:-
{ "data": [ { "type": "ids", "id":function(){eval('console.log(Hello World
)')} } ] }
This is showing error to me
syntaxError: Unexpected token u in JSON at position 35<br> at JSON.parse (<anonymous>)<br> at /Users/acid/node_js/localhost/velekaam/hacked.js:16:19<br> at Layer.handle [as handle_request] (/Users/acid/node_js/node_modules/express/lib/router/layer.js:95:5)<br> at next (/Users/acid/node_js/node_modules/express/lib/router/route.js:137:13)<br> at Route.dispatch (/Users/acid/node_js/node_modules/express/lib/router/route.js:112:3)<br> at Layer.handle [as handle_request]
Can anyone please tell me how I pass
{ "data": [ { "type": "ids", "id":function(){eval('console.log(Hello World
)')} } ] } so that I am able to pass this through de-serializer function and get result as "Hello Word". ?
via Ashu
No comments:
Post a Comment