Recommended way to expose some page data via JSON API

I could manage to output a first json :slight_smile: thanks to @sebobo tipps.
I still needed to add the following to my Site Settings.yaml:

    mvc:
      routes:
        'My.Site':
          position: 'before Neos.Neos'
        'Neos.Neos':
          variables:
            # We prefer URLs without the ".html" suffix
            defaultUriSuffix: ''

else I could only render /.json or /de.json, but NOT /de/some-page/my-page.json. With the config above I could also render a json view for /de/some-page/my-page.json.

@sebobo I don’t understand yet, why the Fusion code is called by calling some-page.json? What is the connnection between this Fusion code “json = …” and the Routes definition? Is it because we define this “json = …” property that Neos knows to render it as json?

Next I try to get the right json data out of the ContentCollection nodes, etc.
Currently my challenge is that I would like to render my ContentCollection node “main” but not as html string, but as structured data. So I’m thinking of somehow to define for each content element (e.g. Button, Headline, Text&Image, Sliders, etc.) some “Json Fusion view” and so I could iterate over these content elements with their Json views. Maybe @sebobo you have also some idea how to solve this :slight_smile: .

Similar topic: How can render single content node with fusion

1 Like