Is it correct to include data as a key name in JSON?

Is it correct to include data as a key name in JSON?

I am consuming an API that is providing a JSON payload. One of the properities in the JSON is actually a data element, thus I'm unable to de-serialize the payload without adding additional classes.

I am consuming an API that is providing a JSON payload. One of the properities in the JSON is actually a data element, thus I'm unable to de-serialize the payload without adding additional classes.

Here is the JSON:

{
      "company": "ABC Inc.",
      "packages": {
          "$package1": {
          "code": "$package1",
          "name": "Foo",
          "price": 1000
        },
        "$package2": {
          "code": "$package2",
          "name": "Bar",
          "price": 2000
        },
        "$package3": {
          "code": "$package3",
          "name": "Another",
          "price": 3000
        }
    }
}

I am able to serialize using Newtonsoft.Json with the following classes:

public class Rootobject
{
    public string company { get; set; }
    public Packages packages { get; set; }
}

public class Packages { public Package1 package1 { get; set; } public Package2 package2 { get; set; } public Package3 package3 { get; set; } }

public class Package1 { public string code { get; set; } public string name { get; set; } public int price { get; set; } }

public class Package2 { public string code { get; set; } public string name { get; set; } public int price { get; set; } }

public class Package3 { public string code { get; set; } public string name { get; set; } public int price { get; set; } }

Using this approach I can de-serialize using Newtonsoft.Json, but if "package4" is added later, then it requires me to make a code change.

Should I push back on the developer of this API and insist on an array of packages, rather than how it is currently implemented?

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

C/C++ vs. Rust: A developer’s perspective

In this post, you'll see the difference between Rust and C/C++ in a developer’s perspective

Variable Introduction in C#[Bangla]

LIKE | COMMENT | SHARE | SUBSCRIBE A variable is nothing but a name given to a storage area that our programs can manipulate. Each variable in C# has a speci...