Json object giving null value after sending json array to the sling Servlet
Hi All,
I have created Sling Servlet and I wanted to pass json raw data to the Slingservlet but it is showing null values.

please check anything that I missed.
Hi All,
I have created Sling Servlet and I wanted to pass json raw data to the Slingservlet but it is showing null values.

please check anything that I missed.
Hi @sanjay_bangar ,
When doing a ajax call use something like below
var square = {};
square.length = 10;
square.width = 10;
$.ajax(
url: url,
data: JSON.stringify(square),
dataType: “json”
contentType: “application/json”,
);
while reading in servlet you can use like below:
String requestBody = request.getReader().lines().collect(Collectirs.joining());
you can use any Utils class to convert from string to json or java bean.
Thanks!
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.