Imagine there is an object called a
with properties:
const a = {
foo: 123,
bar: 'example'
}
Now, this object is a part of another object called b
like this:
const b = {
a: a,
anotherField: "example"
}
While working with TypeScript, these objects belong to the same class but it's not crucial.
When converting the b
object to JSON, the desired string is:
{ a: 123, anotherField: "example" }
How can we instruct JSON.stringify()
to format the a
object in this way?
Perhaps something akin to the features available in Python
could be useful.