AnsweredAssumed Answered

Escaping slashes in JSON - seeming Catch 22

Question asked by CamelCase_data Expert on Oct 6, 2017
Latest reply on Apr 26, 2018 by bigtom

In FileMaker 16, I need to generate JSON for a web service (MailChimp) to upload, among other things, some html.

 

The JSONSetElement takes care of a lot of the escaping, but in this html, there is an additional requirement to escape slashes with a backslash.

 

So in other words:

http://www.filemaker.com/

should be

http:\/\/www.filemaker.com\/

 

However, one of the characters that JSONSetElement does escape is of course the backslash, which means that:

 

JSONSetElement ( $json ; "html" ;

Substitute (

"http://www.filemaker.com/"

; "/" ; Char ( 92 ) & "/" )

; JSONString )

 

returns

 

{"html":"http:\\/\\/www.filemaker.com\\/"}

 

(with double backslashes) and not

 

{"html":"http:\/\/www.filemaker.com\/"}

 

Does anyone have a suggestion as to what I'm missing or ideas for possible workarounds (not involving plugins or shell scripting).

Outcomes