I try to serialize some webservice parameters using Gson and I get a strange error:
11-03 00:56:43.088: **.helpers.JsonServer(620): Result data: {"Message":"Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.\r\nParameter name: input","StackTrace":" at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit)\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"}
The parameteres I try to serialize are some strings and numbers, but the issue is when I have a big string (a base64 image) as parameter.
I didn't find a way to increase the depthLimit in Gson object. Any idea?
my code looks like this:
Gson gson = new Gson();
httpPost.setEntity(new StringEntity(gson.toJson(parameters), "utf-8")); //here I get the error
httpPost.setHeader("Content-Type", "application/json; charset=utf-8");
parameters is a Hashtable. One of the items in this hash is a big (more than 600k chars) string - the base64 image. This image can be bigger some time - more than 1M.
Question: How to increase that limit