on 01-21-2020 6:53 AM
Dear All,
I am trying to Convert a Json to XML. In the input json, I have a hexa decimal character - \u000f
Because of that, JSON to XML conversion fails. I am trying to replace the hexa decimal character by using replace method in the String. But it is not getting replaced. The same code works well in my local groovy script.
Input Payload:
{"address":"\u000fF"}
Error Message:
An internal server error occured: Invalid white space character (0xf) in text to output (in xml 1.1, could output as a character entity).
Note: When I tried to see the length of the Body Message, I am getting it as 21 for the input payload. But in my local, its length is 16. The Hexa decimal character is not recognized as single character in SCPI.
Please provide your suggestion to solve the issue
Hi Selvakumar,
have your tried double escaping the backslash? This one works for me:
body = body.replaceAll("\\u000f",'')
Best regards,
Raffael
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, I solved this problem using this, Coding a literal backslash into a regex requires 4 backslashes in the java/groovy literal String, because the backslashes are escaped twice - once in java/groovy and again in the regex.
def jsonOP = message.getBody(String.class);
jsonOP=jsonOP.toString().replaceAll("\\\\u[0-9a-fA-F]{4}", "") //replacing non-printable characters
message.setBody(jsonOP);
return message;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
with "\\"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try to use replaceAll method as can you see below:
xx0F = x0F.replaceAll("\\u000f","")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.