Skip to content

JSON fields are ordered differently when exceeding 8 fields per object #10699

@kamal-choudhary

Description

@kamal-choudhary

Bug report

Describe the bug

I have a JSON data field in one of my content types. It works perfectly fine until the number of fields inside the JSON object is either 8 or less than 8. As soon as I introduce field number 9, the order of JSON fields gets changed.

Steps to reproduce the behavior

  1. Add a JSON data field in your content type
  2. Go to your content type and create an entry
  3. Add some valid JSON for the JSON field, it works fine until the number of fields inside the JSON object is either 8 or less than 8
  4. Added field number 9 and the ordering of fields will get changed.

Expected behavior

The ordering of fields should not change. Items should be ordered as entered.

Code snippets

Let’s say I have a Person type JSON-LD object and I add only 8 fields in this format:

{
  "@context": "https://schema.org",
  "@type": "Person",
  "name": "Jane Doe",
  "url": "http://www.janedoe.com",
  "sameAs": "sdfsdfsdf",
  "jobTitle": "CEO",
  "image": "janedoe.jpg",
  "description": "jane doe description"
}

Until this moment, it is perfectly fine.

But if I add a new field like “memberOf”, then the ordering of the fields gets changed.

{
  "name": "Jane Doe",
  "url": "http://www.janedoe.com",
  "@context": "https://schema.org",
  "memberOf": "janedoewebsite.com",
  "sameAs": "sdfsdfsdf",
  "@type": "Person",
  "jobTitle": "CEO",
  "image": "janedoe.jpg",
  "description": "jane doe description"
}

The whole ordering of fields has been changed by introducing field 9.

System

  • Node.js version: 14.15.3
  • NPM version: 6.14.9
  • Strapi version: 3.6.3
  • Database: SQLite locally, postgreSQL on Production
  • Operating system: macOS Big Sur

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue: bugIssue reporting a bugseverity: lowIf the issue only affects a very niche base of users and an easily implemented workaround can solvesource: core:content-managerSource is core/content-manager packagestatus: confirmedConfirmed by a Strapi Team member or multiple community members

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions