cancel
Showing results for 
Search instead for 
Did you mean: 

XML to JSON Structure for conversion of String to String getting error in sap HCI

0 Kudos

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

Accepted Solutions (0)

Answers (1)

Answers (1)

Sriprasadsbhat
Active Contributor
0 Kudos

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