You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Niraj <ni...@gmail.com> on 2013/07/24 12:39:56 UTC
Issue while passing JSON string to AJAX request
Hello,
I am sending one ajax request to the server
http://localtest/Web/AjaxService.asmx/Request?id=e519e615b0e01d6e80679-a353
Post data:
{"id":"e519e615b0e01d6e80679-a353","nodeId":"WVM","callback":"","args":"{\"viewId\":\"87ec8bd6-b5e4-476d-93ad-4bbbbd6728c2\",\"method\":\"ModifyControl\",\"args\":\"{\\"id\\":\\"eed9f0aeae7e4f83b90f1d76f4619d88\\",\\"args\\":null}\"}"}
But when i send this using JMeter, i am getting below error
{"Message":"Invalid object passed in, \u0027:\u0027 or \u0027}\u0027
expected. (172):
{\"waid\":\"e519e615b0e01d6e80679-a353\",\"nodeId\":\"WVM\",\"callback\":\"\",\"args\":\"{\\\"viewId\\\":\\\"87ec8bd6-b5e4-476d-93ad-4bbbbd6728c2\\\",\\\"method\\\":\\\"ModifyControl\\\",\\\"args\\\":\\\"{\\\\\"id\\\\\":\\\\\"eed9f0aeae7e4f83b90f1d76f4619d88\\\\\",\\\\\"args\\\\\":null}\\\"}\"}","StackTrace":"
at
System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeDictionary(Int32
depth)\r\n at
System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32
depth)\r\n at
System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasicDeserialize(String
input, Int32 depthLimit, JavaScriptSerializer serializer)\r\n at
System.Web.Script.Serialization.JavaScriptSerializer.Deserialize[T](String
input)\r\n at
System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext
context, WebServiceMethodData
methodData)","ExceptionType":"System.ArgumentException"}
Can some please help me to resolve the issue?
Thanks,
Niraj
Re: Issue while passing JSON string to AJAX request
Posted by Niraj <ni...@gmail.com>.
Thanks a lot Flavio. Your answer gave me right direction to resolve my
issue. Thanks once again for your valuable inputs.
On Jul 24, 2013 7:21 PM, "Flavio Cysne" <fl...@gmail.com> wrote:
> I tested creating a variable, inside my browser console, using those two
> JSON strings presented in your e-mail and both returned "Unexpected token
> ILLEGAL" error.
>
> Then I tried the JSON string below and it worked.
>
> var myObject =
>
> {"id":"e519e615b0e01d6e80679-a353","nodeId":"WVM","callback":"","args":'{"viewId":"87ec8bd6-b5e4-476d-93ad-4bbbbd6728c2","method":"ModifyControl","args":"{\"id\":\"eed9f0aeae7e4f83b90f1d76f4619d88\",\"args\":null}"}'};
>
> See that I changed the approach of using only quotes for defining string
> values and used apostrophes for the args attribute (the first one). I also
> removed the extra slashes that turned obsolete because I could use quotes
> inside apostrophes without problems.
>
> Maybe using extra slashes could do the work. Anyway, I suppose you are
> creating these strings manually, so it should not be an issue for you to
> change quotes for apostrophes.
>
>
> 2013/7/24 Niraj <ni...@gmail.com>
>
> > Hello,
> >
> > I am sending one ajax request to the server
> >
> >
> http://localtest/Web/AjaxService.asmx/Request?id=e519e615b0e01d6e80679-a353
> >
> > Post data:
> >
> >
> {"id":"e519e615b0e01d6e80679-a353","nodeId":"WVM","callback":"","args":"{\"viewId\":\"87ec8bd6-b5e4-476d-93ad-4bbbbd6728c2\",\"method\":\"ModifyControl\",\"args\":\"{\\"id\\":\\"eed9f0aeae7e4f83b90f1d76f4619d88\\",\\"args\\":null}\"}"}
> >
> > But when i send this using JMeter, i am getting below error
> >
> > {"Message":"Invalid object passed in, \u0027:\u0027 or \u0027}\u0027
> > expected. (172):
> >
> >
> {\"waid\":\"e519e615b0e01d6e80679-a353\",\"nodeId\":\"WVM\",\"callback\":\"\",\"args\":\"{\\\"viewId\\\":\\\"87ec8bd6-b5e4-476d-93ad-4bbbbd6728c2\\\",\\\"method\\\":\\\"ModifyControl\\\",\\\"args\\\":\\\"{\\\\\"id\\\\\":\\\\\"eed9f0aeae7e4f83b90f1d76f4619d88\\\\\",\\\\\"args\\\\\":null}\\\"}\"}","StackTrace":"
> > at
> >
> >
> System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeDictionary(Int32
> > depth)\r\n at
> >
> >
> System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32
> > depth)\r\n at
> >
> >
> System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasicDeserialize(String
> > input, Int32 depthLimit, JavaScriptSerializer serializer)\r\n at
> >
> System.Web.Script.Serialization.JavaScriptSerializer.Deserialize[T](String
> > input)\r\n at
> > System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext
> > context, WebServiceMethodData
> > methodData)","ExceptionType":"System.ArgumentException"}
> >
> > Can some please help me to resolve the issue?
> >
> > Thanks,
> > Niraj
> >
>
Re: Issue while passing JSON string to AJAX request
Posted by Flavio Cysne <fl...@gmail.com>.
I tested creating a variable, inside my browser console, using those two
JSON strings presented in your e-mail and both returned "Unexpected token
ILLEGAL" error.
Then I tried the JSON string below and it worked.
var myObject =
{"id":"e519e615b0e01d6e80679-a353","nodeId":"WVM","callback":"","args":'{"viewId":"87ec8bd6-b5e4-476d-93ad-4bbbbd6728c2","method":"ModifyControl","args":"{\"id\":\"eed9f0aeae7e4f83b90f1d76f4619d88\",\"args\":null}"}'};
See that I changed the approach of using only quotes for defining string
values and used apostrophes for the args attribute (the first one). I also
removed the extra slashes that turned obsolete because I could use quotes
inside apostrophes without problems.
Maybe using extra slashes could do the work. Anyway, I suppose you are
creating these strings manually, so it should not be an issue for you to
change quotes for apostrophes.
2013/7/24 Niraj <ni...@gmail.com>
> Hello,
>
> I am sending one ajax request to the server
>
> http://localtest/Web/AjaxService.asmx/Request?id=e519e615b0e01d6e80679-a353
>
> Post data:
>
> {"id":"e519e615b0e01d6e80679-a353","nodeId":"WVM","callback":"","args":"{\"viewId\":\"87ec8bd6-b5e4-476d-93ad-4bbbbd6728c2\",\"method\":\"ModifyControl\",\"args\":\"{\\"id\\":\\"eed9f0aeae7e4f83b90f1d76f4619d88\\",\\"args\\":null}\"}"}
>
> But when i send this using JMeter, i am getting below error
>
> {"Message":"Invalid object passed in, \u0027:\u0027 or \u0027}\u0027
> expected. (172):
>
> {\"waid\":\"e519e615b0e01d6e80679-a353\",\"nodeId\":\"WVM\",\"callback\":\"\",\"args\":\"{\\\"viewId\\\":\\\"87ec8bd6-b5e4-476d-93ad-4bbbbd6728c2\\\",\\\"method\\\":\\\"ModifyControl\\\",\\\"args\\\":\\\"{\\\\\"id\\\\\":\\\\\"eed9f0aeae7e4f83b90f1d76f4619d88\\\\\",\\\\\"args\\\\\":null}\\\"}\"}","StackTrace":"
> at
>
> System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeDictionary(Int32
> depth)\r\n at
>
> System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32
> depth)\r\n at
>
> System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasicDeserialize(String
> input, Int32 depthLimit, JavaScriptSerializer serializer)\r\n at
> System.Web.Script.Serialization.JavaScriptSerializer.Deserialize[T](String
> input)\r\n at
> System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext
> context, WebServiceMethodData
> methodData)","ExceptionType":"System.ArgumentException"}
>
> Can some please help me to resolve the issue?
>
> Thanks,
> Niraj
>