I am sending an image file along with other form elements in my java application. Before sending my content to API, in JS ajax call, I am using
if (content != "") {
sendData = JSON.parse(content);
}
since the byte array contains \, "" and other characters, JSON parsing fails here. Is there any way to encode the byte array and decode it in service layer? Please help me. Thanks in advance.
content != ""will always be true (even ifcontentisnullor an empty string), unless you have explicitly assignedcontent = "".falsefor empty strings, don't you? Well, it is not what you are getting...