Hi ramitaherwahdan1978,
First you need to initialize an object of the variable you want to convert to a json data.
Then, you can use JSON.stringify which is a built-in method of JavaScript.
JSON.stringify is used to convert JavaScript objects or values to a json string or json data.
Refer the following link for more information.
https://stackoverflow.com/questions/38372134/how-to-convert-an-object-to-json-correctly-in-angular-2-with-typescript