Adding double quotes to JSON call

QuestionsCategory: QuestionsAdding double quotes to JSON call
Ryan Curtin asked 3 years ago

I am looking for a good way to add double quotes to all fields and variables to a specific JSON formatted string… Is there way to easily do this in the xlate or as part of the json format. if not can someone help provide a tcl example script?

I have


and I want


Ryan Curtin replied 3 years ago

%5B%5D are open and closed brackets [] and &#8221 ” is a double quote im not sure why this website change it to the encoded characters.

Josh Myers replied 3 years ago

We've had to do similar things with json. You can use "string map" or "regsub" commands.

string map example:

set icd9 [list {"icd9_list": ""} {"icd9_list": [{""}]}]
set icd10 [list {"icd10_list": ""} {"icd10_list": [{""}]}]
set msg [string map $icd9 $msg]
set msg [string map $icd10 $msg]


regsub {\[\r\n} $msgText {} msgText
regsub -all {,\r\n} $msgText "\n" msgText
regsub {\r\n\]} $msgText {} msgText

For your use case, regsub -all may be the better option but it is going to be tricky to account for all the scenarios:
, -> ,"
{ -> {"
: -> ":"

Levy Lazarre replied 3 years ago

I would like to revisit this interesting topic. Ryan, have you found a satisfactory way to complete the task?

Related Articles


If you already had an existing account on the older server, your username has been imported. However, you can login with your email address. Your old password should still work. But if it doesn't (or you can remember it), then be sure to click on "Forgot Your Password" and follow the instructions!

If you need additional help, please email for additional help and support.

We appreciate your patience!