The below code shows the JSON response being returned during the MS Graph operation.
Other Examples
Calling REST API or MS Azure function from SPFx returns the response in the JSON format.
Process JSON in SPFx Code
In SPFx solutions, we define an interface to represent the data returned from JSON and use it in our code. To define the interface, firstly we have to analyze the JSON data and its format. If the JSON response is complicated, creating the interface by hand to represent it is a difficult job. Also, the interface should be revised if there is a change in the returned JSON (e.g. addition of new field, removal of an existing field, rename of fields, reposition of fields, etc.)
Paste JSON as Code – VSO Extension
An extension “Paste JSON as Code” for Visual Studio Code is available in the marketplace for free to help convert JSON to any language.
This extension can prove handy to convert JSON to any language including TypeScript, Python, Go, Ruby, C#, Java, Swift, Rust, Kotlin, C++, Flow, Objective-C, JavaScript, Elm, and JSON Schema.
Follow the below steps to install the extension to VSO.