strapi-community / strapi-plugin-transformer

A plugin for Strapi Headless CMS that provides the ability to transform the API request or response.
https://market.strapi.io/plugins/strapi-plugin-transformer
MIT License
140 stars 22 forks source link

remove "data" property from JSON Datatype #79

Open alexzrp opened 1 year ago

alexzrp commented 1 year ago

To reproduce:

  1. Create a collection with JSON field
  2. Insert in JSON field the content: [{"data": 1}, {"data": "test"}]
  3. Transform remove "data" from JSON content.

This isn't a relation field.

alexzrp commented 1 year ago

the same occour if in content exist "attributes" and flag removeAttribute is true

ComfortablyCoding commented 1 year ago

Thanks for submitting this issue! I assume it is a fairly small use case as this is the first report for this issue but I will look into it. Not an intended behaviour.

sven-ra commented 1 year ago

Running into the same issue here. I am using JSON field to generate charts.

An example chart JSON looks like this:

{
  "labels": [
    "Red",
    "Blue",
    "Yellow",
    "Green",
    "Purple",
    "Orange"
  ],
  "datasets": [
    {
      "label": "# of Votes",
      "data": [
        12,
        19,
        3,
        5,
        2,
        3
      ],
      "backgroundColor": [
        "rgba(255, 99, 132, 0.2)",
        "rgba(54, 162, 235, 0.2)",
        "rgba(255, 206, 86, 0.2)",
        "rgba(75, 192, 192, 0.2)",
        "rgba(153, 102, 255, 0.2)",
        "rgba(255, 159, 64, 0.2)"
      ],
      "borderColor": [
        "rgba(255, 99, 132, 1)",
        "rgba(54, 162, 235, 1)",
        "rgba(255, 206, 86, 1)",
        "rgba(75, 192, 192, 1)",
        "rgba(153, 102, 255, 1)",
        "rgba(255, 159, 64, 1)"
      ],
      "borderWidth": 1
    }
  ]
}

And the API output looks like this:

{
  "labels": [
    "Red",
    "Blue",
    "Yellow",
    "Green",
    "Purple",
    "Orange"
  ],
  "datasets": [
    [
      12,
      19,
      3,
      5,
      2,
      3
    ]
  ]
}