on 10-13-2018 10:22 AM
My Requirement is:
Json Structure String to String
It is not working getting this error:
Input Payload:
{
"name":"naveen"
}
Output Payload:
{
"name": naveen
}
Error:
java.lang.Exception: java.lang.NumberFormatException: For input string: "naveen"@ line 13 in RemoveQuotes.groovy
JSON Structure String to Integer
as per the code it is working fine
{
"name":"1000"
}
Output Payload:
{
"name": 1000
}
but i need to remove that double quotes in char, Please help me to complete my requirement.Below code is String to integer. Please help me for converting String to String by removing double quotes symbol.Please give me groovy code to convert string to string removing double quotes
JSON Code for conversion of String to Integer it is converting
import com.sap.gateway.ip.core.customdev.util.Message;import java.util.HashMap;import groovy.json.*
def Message processData(Messagemessage){//Body
def body =message.getBody(String.class);
def jsonSlurper =new JsonSlurper()
def list= jsonSlurper.parseText(body)list.Root.each{
it.name=Integer.parseInt(it.get("name").toString().replace(" ","")); }
def jsonOP = JsonOutput.toJson(list)message.setBody(jsonOP)returnmessage;}
I need to convert String to String
Hello Naveen,
I could see multiple threads are created fir same question .Could you please delete rest of the threads and keep only one thread.
Regards,
Sriprasad Shi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
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.