I have never used Frisby or superagent, but I find there are two questions here:
1. passing an invalid JSON from client to server using POST method.
Which is not possible because , it will be soon rejected at the client side itself, and you will get error before making a POST request to the server. (because as there are only strings while working with http, the client will itself try to stringify the JSON where it will get stuck with invalid JSON)
2. pass an invalid JSON just as a string
example: POST a string like this using JQuery
$.post("demo_test_post.asp",
{
name: 'pqr:{"abc":"abc",}' // see there is a comma at the end making JSON invalid
},
function(data, status){
alert("Data: " + data + "\nStatus: " + status);
});
This will effectively pass the invalid JSON (name in this case) to the server as a srting. But this will require you to parse the string to JSON using JSON.parse()
before you can use it. And when you try that you get this:
SyntaxError: Unexpected token p at Object.parse (native) at
Object.app.get.res.send.data [as handle]
(/home/ubuntu/workspace/TapToBook.js:35:19) at next_layer
(/home/ubuntu/workspace/node_modules/express/lib/router/route.js:103:13)
at Route.dispatch
(/home/ubuntu/workspace/node_modules/express/lib/router/route.js:107:5)
at proto.handle.c
(/home/ubuntu/workspace/node_modules/express/lib/router/index.js:195:24)
at Function.proto.process_params
(/home/ubuntu/workspace/node_modules/express/lib/router/index.js:251:12)
at next
(/home/ubuntu/workspace/node_modules/express/lib/router/index.js:189:19)
at Layer.staticMiddleware [as handle]
(/home/ubuntu/workspace/node_modules/express/node_modules/serve-static/index.js:55:61)
at trim_prefix
(/home/ubuntu/workspace/node_modules/express/lib/router/index.js:226:17)
at proto.handle.c
(/home/ubuntu/workspace/node_modules/express/lib/router/index.js:198:9)
So whichever packages you use for Rest, you can pass invalid JSON as a string, but not use it.