I'm running a SpringBoot + MongoDB project where I have tons of object references in my database. In my controllers I would like to output objects in JSON with "proxy" placeholders instead of the real objects in the references.
For example I am currently getting the following output
"inputThing" : {
"name" : "some name",
"length" : 16,
"formats" : [
{
"format" : "decimal", <-- "_id" : "1"
"type" : "some type"
}, {
"format" : "octal", <-- "_id" : "2"
"type" : "some other type"
}, {
"format" : "hexadecimal", <-- "_id" : "3"
"type" : "yet another type"
} ]
}
and I would instead like to have this output with "proxy" references
"inputThing" : {
"name" : "some name",
"length" : 16,
"formats" : [
{
"_id" : "1"
}, {
"_id" : "2"
}, {
"_id" : "3"
} ]
}
So that the produced json is less heavy, and clients can get the object with id "1" using another controller handler.
Any ideas how to do this? Thx