Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
RVeitch_84
Creator
Creator

Escaping Character with a global variable in the middle

I need to pass this as a string in tJava and I need to escape the double qoutes with a variable in the middle .

String cursor2;

cursor2 = " \"cursor\" " + ":" + row5.cursor ;

context.Body="{\"location_ids\":[\"" + (String) globalMap.get("locations") +"\"], \"" + cursor2 + "\"}" ;

Here is the cuurent result, I'm missing the double quotes in front of the g and I have an extra infront of the word cursor?

body {"location_ids":["27NA2Q0DDW471"], " "cursor" :gc7IdfFn6y61gTgvVxFSTIw9xHVpRnr7oggL"}

I need my body to look like this.

body {"location_ids":["27NA2Q0DDW471"], "cursor" :"gc7IdfFn6y61gTgvVxFSTIw9xHVpRnr7oggL"}

Any help would be appreciated.

Bob

Labels (4)
1 Solution

Accepted Solutions
RVeitch_84
Creator
Creator
Author

Thanks, I fixed it with

 

cursor2 = " \"cursor\" :" + "\"" + row5.cursor + "\"}" ;

context.Body="{\"location_ids\":[\"" + (String) globalMap.get("locations") + "\"]," + cursor2 ;

View solution in original post

2 Replies
Anonymous
Not applicable

Hi

For debugging, print the value of row5.cursor on the console to check if it has the expected value.

cursor2 = " \"cursor\" " + ":" + row5.cursor;

System.out.println(row5.cursor);

System.out.println(cursor2);

 

Regards

Shong

 

RVeitch_84
Creator
Creator
Author

Thanks, I fixed it with

 

cursor2 = " \"cursor\" :" + "\"" + row5.cursor + "\"}" ;

context.Body="{\"location_ids\":[\"" + (String) globalMap.get("locations") + "\"]," + cursor2 ;