How to Include Double Quotes in a String
In Bold Reports, there are often scenarios where you need to include double quotes within a string. Whether you’re generating dynamic text or incorporating data from external sources, the ability to handle double quotes is crucial. In this article, we’ll explore how to include double quotes in strings using the CHAR(34) function in Bold Reports.
Example Expression for Web API Request Body
To include double quotes in a JSON payload, you can use the Chr(34)
function in your expression as shown below:
="{" &
Chr(34) & "id" & Chr(34) & ":" & Chr(34) & 1 & Chr(34) & "," &
Chr(34) & "name" & Chr(34) & ":" & Chr(34) & Parameters!Name.Value &
"}"
This expression generates a JSON object with the following structure:
{
"id": 1,
"name": "Ram" //This value comes from the name parameter.
}
Steps to use Chr(34)
in JSON payloads in Bold Reports
To include double quotes in your JSON payload using Chr(34) in the Bold Reports application, follow these steps:
- In your Web API datasource, use your REST API endpoint in the URL text box to perform a
POST
action. - Select
POST
in the Method drop-down and switch to the Raw radio button. A text area with an option to set an expression will be displayed. - Choose the Expression option from the menu to launch the expression dialog.
- Enter the expression like the example code above and click OK.
- Enter valid raw details in the required fields and click OK to confirm.
- Your data source is now successfully created with the correct JSON payload.
Using the Chr(34)
function is a simple yet effective way to include double quotes in JSON strings, ensuring that your JSON payloads are correctly formatted for Web API requests.
See also
For additional information on connecting to a Rest API data source, you can refer to the following link.