Let's say I have an object:
const a = {
foo: 123,
bar: 'example'
}
This object is a part of many other objects i.e.
const b = {
a: a,
anotherField: "example"
}
Actually, I'm using TypeScript and all these objects are of the same class which I believe isn't important.
After serializing the b object to JSON I need to get this string (i.e. I just get the foo field from a):
{ a: 123, anotherField: "example" }
What is the easiest and most elegant way to tell JSON.stringify() how to convert the a object to a string?
Probably something similar to what Python allows.
JSON.stringifywill convert to string that js object.