Converting PageState to a Map

As part of a task to create a JSON API for single pages of a site, I want to generate a map with all fields found in .Page and add fields not available there (e.g .Summary, .Params etc.). To accomplish this, the best I could manage was

{{ $page := . }}
{{ $pageMap := (jsonify $page) | transform.Unmarshal }}
{{ $pageMap = merge $pageMap (dict "Params" $page.Params "Summary" $page.Summary "Content" $page.Content) }}
{{ jsonify $pageMap }}

While this works fine, the marshaling and then unmarshaling is making me a bit uncomfortable that here must be a better/straightforward way to do this. Is there?

Thanks as always.

Not that I can think of.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.