How do I convert a YailList to String and replace double quotes with single quotes?

And extension passes that value to js which is run in WebView.
There are some issues with string conversion between Java and JavaScript.
When you run a js query in WebView to return a string result then you will get that value as already escaped (wrapped in ").
Similarly when you pass a string either wrapped in " or ', that's actually treated as String in JavaScript.
For example, see this snippet from @Taifun (He can shed more light on this topic):

So to conclude this I would say "'string'" (Java) is treated as "string" in JavaScript and "string" (JavaScript) is treated as ""string"" in Java.

Not sure if this is relevant here.

The String htmlcode is constructing a long string of html to be set to file which is then run in a webviewer.
All I want to do is add a string as a variable to that html. As you have seen this works if I send a string by converting the list in the app, but it would be better to get users to simply add the list to the extension blocks, and then convert the "list" (whatever it is) to a string in the java code.

Java, for whatever reason, does not appear to want to do this, without having to iterate over the items in the list, even though this appears trivial when using blocks.....

1 Like

Only method which I can think is going to work is to iterate over each item and wrap that in ' .
Or you actually don't need to do anything.Because " and ' are same in JavaScript.

1 Like

Yes, that appears to work OK, which gets me down to this:

:smiley:

1 Like

In fact this works as well:

in which case this whole topic was "much ado about nothing"

:smiley: :smiley:

1 Like

Many thanks to everyone today for chipping in and having a go, @oseamiya, @Kumaraswamy, @vknow360, and @shreyash.

Through trial and error, prompted by your inputs, I discovered that by setting the "list" to a String in the Simple Function, it was automatically converted it to a string, and with @vknow360 's help found that I could ignore the " that I wanted to be ' . All is well, although I could be a lot further along if I had found this in the first place. Oh well :wink:

4 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.