Nested types example
The introductory example features a standalone class. Let's look at a more involved example that builds on top of that:
Notice that the data contains a list of pets (Animal
).
Again, our goal is to parse JSON into JavaScript classes to be able to do things like
Note: pets() returns a Modelico.List
, which has a get
method, but little more. To map
, filter
or perform other operations, you will need to grab the underlying array with .inner()
. See the proxies docs for a way to use methods and properties of the inner structure directly.
To achieve our goal, we need a Person
that references Animal
within its inner types using the M.metadata()._
function.
Last updated