limbo-works / Limbo.Umbraco.Tables

Table editor for Umbraco.
https://packages.limbo.works/limbo.umbraco.tables/
MIT License
6 stars 8 forks source link

Feature: clean output for Content Delivery API in V12 #16

Closed cf-marc closed 1 year ago

cf-marc commented 1 year ago

Hello

We are using the Content Delivery API of Umbraco 12. The output is useable, but there are some empty elements inside the response. Also we are using the option for the richtext editor to send JSON instead of html.

"content": {
                        "id": "f1b43dda-450f-4342-8aba-2779ad2b11dc",
                        "contentType": "contentTable",
                        "properties": {
                            "jumpNavigationTitle": null,
                            "title": "Preise",
                            "table": {
                                "useFirstRowAsHeader": false,
                                "useFirstColumnAsHeader": false,
                                "rows": [
                                    {
                                        "index": 0,
                                        "jObject": {}
                                    },
                                    {
                                        "index": 1,
                                        "jObject": {}
                                    }
                                ],
                                "columns": [
                                    {
                                        "index": 0,
                                        "jObject": {}
                                    },
                                    {
                                        "index": 1,
                                        "jObject": {}
                                    },
                                    {
                                        "index": 2,
                                        "jObject": {}
                                    }
                                ],
                                "cells": [
                                    [
                                        {
                                            "rowIndex": 0,
                                            "row": {
                                                "index": 0,
                                                "jObject": {}
                                            },
                                            "columnIndex": 0,
                                            "column": {
                                                "index": 0,
                                                "jObject": {}
                                            },
                                            "value": "<p>Col 1</p>",
                                            "type": "td",
                                            "scope": null,
                                            "jObject": {
                                                "rowIndex": [],
                                                "columnIndex": [],
                                                "value": [],
                                                "type": [],
                                                "scope": []
                                            }
                                        },
                                        {
                                            "rowIndex": 0,
                                            "row": {
                                                "index": 0,
                                                "jObject": {}
                                            },
                                            "columnIndex": 1,
                                            "column": {
                                                "index": 1,
                                                "jObject": {}
                                            },
                                            "value": "<p>Col2</p>",
                                            "type": "td",
                                            "scope": null,
                                            "jObject": {
                                                "rowIndex": [],
                                                "columnIndex": [],
                                                "value": [],
                                                "type": [],
                                                "scope": []
                                            }
                                        },
                                        {
                                            "rowIndex": 0,
                                            "row": {
                                                "index": 0,
                                                "jObject": {}
                                            },
                                            "columnIndex": 2,
                                            "column": {
                                                "index": 2,
                                                "jObject": {}
                                            },
                                            "value": "<p>Col3</p>",
                                            "type": "td",
                                            "scope": null,
                                            "jObject": {
                                                "rowIndex": [],
                                                "columnIndex": [],
                                                "value": [],
                                                "type": [],
                                                "scope": []
                                            }
                                        }
                                    ],
                                    [
                                        {
                                            "rowIndex": 1,
                                            "row": {
                                                "index": 1,
                                                "jObject": {}
                                            },
                                            "columnIndex": 0,
                                            "column": {
                                                "index": 0,
                                                "jObject": {}
                                            },
                                            "value": "<p>Text</p>",
                                            "type": "td",
                                            "scope": null,
                                            "jObject": {
                                                "rowIndex": [],
                                                "columnIndex": [],
                                                "value": [],
                                                "type": [],
                                                "scope": []
                                            }
                                        },
                                        {
                                            "rowIndex": 1,
                                            "row": {
                                                "index": 1,
                                                "jObject": {}
                                            },
                                            "columnIndex": 1,
                                            "column": {
                                                "index": 1,
                                                "jObject": {}
                                            },
                                            "value": "<p>Text</p>",
                                            "type": "td",
                                            "scope": null,
                                            "jObject": {
                                                "rowIndex": [],
                                                "columnIndex": [],
                                                "value": [],
                                                "type": [],
                                                "scope": []
                                            }
                                        },
                                        {
                                            "rowIndex": 1,
                                            "row": {
                                                "index": 1,
                                                "jObject": {}
                                            },
                                            "columnIndex": 2,
                                            "column": {
                                                "index": 2,
                                                "jObject": {}
                                            },
                                            "value": "<p>Text</p>",
                                            "type": "td",
                                            "scope": null,
                                            "jObject": {
                                                "rowIndex": [],
                                                "columnIndex": [],
                                                "value": [],
                                                "type": [],
                                                "scope": []
                                            }
                                        }
                                    ]
                                ],
                                "jObject": {
                                    "rows": [
                                        [],
                                        []
                                    ],
                                    "columns": [
                                        [],
                                        [],
                                        []
                                    ],
                                    "cells": [
                                        [
                                            [
                                                [
                                                    []
                                                ],
                                                [
                                                    []
                                                ],
                                                [
                                                    []
                                                ],
                                                [
                                                    []
                                                ],
                                                [
                                                    []
                                                ]
                                            ],
                                            [
                                                [
                                                    []
                                                ],
                                                [
                                                    []
                                                ],
                                                [
                                                    []
                                                ],
                                                [
                                                    []
                                                ],
                                                [
                                                    []
                                                ]
                                            ],
                                            [
                                                [
                                                    []
                                                ],
                                                [
                                                    []
                                                ],
                                                [
                                                    []
                                                ],
                                                [
                                                    []
                                                ],
                                                [
                                                    []
                                                ]
                                            ]
                                        ],
                                        [
                                            [
                                                [
                                                    []
                                                ],
                                                [
                                                    []
                                                ],
                                                [
                                                    []
                                                ],
                                                [
                                                    []
                                                ],
                                                [
                                                    []
                                                ]
                                            ],
                                            [
                                                [
                                                    []
                                                ],
                                                [
                                                    []
                                                ],
                                                [
                                                    []
                                                ],
                                                [
                                                    []
                                                ],
                                                [
                                                    []
                                                ]
                                            ],
                                            [
                                                [
                                                    []
                                                ],
                                                [
                                                    []
                                                ],
                                                [
                                                    []
                                                ],
                                                [
                                                    []
                                                ],
                                                [
                                                    []
                                                ]
                                            ]
                                        ]
                                    ],
                                    "useFirstRowAsHeader": [],
                                    "useFirstColumnAsHeader": []
                                }
                            }
                        }
                    }
abjerner commented 1 year ago

Hi @cf-marc

I think the jObject properties are outputted as the new Content Delivery API uses System.Text.Json, and not Newtonsoft.Json for JSON serialization, and therefore the properties are not being ignored as intended. That should be somewhat easy to fix, so I will look into that.

Outputting the RTE as JSON is however a bit more tricky. This package currently targets Umbraco 10, and as there aren't any breaking changes in Umbraco 11 and 12 affecting this package, Umbraco 11 and 12 are therefore supported as well.

Targeting Umbraco 12 and thereby adding support for the content delivery API is not something I can do for v1 of this package. Introducing another major version of this package and simultaneously having two active major versions of the package requires more time. And as an agency, we're sticking with Umbraco's LTS releases. So this is not likely a feature we're going to work on for Umbraco 12, but I could see this being implemented when Umbraco 13 comes around.

I hope that makes sense 😉

abjerner commented 1 year ago

A v1.1 release will be out either later today or some time next week. This release will address the issues with JSON serialization when using System.Text.Json instead of Newtonsoft.Json. When testing, either framework will now generate the same JSON output.