Back

Invalid document structure: Missing required attribute "Date"

  • 0
  • Self Hosted
  • Databases
  • General
Drake
26 Sep, 2023, 22:30

How about if you get rid of the JsonProperty decorators/annotations?

TL;DR
Issue: "Invalid document structure: Missing required attribute 'Date'" Messages: There is a discussion about the Newtonsoft.Json library and its default behavior of converting PascalCase to camelCase in JSON serialization. The user suggests using the [JsonProperty("propertyName")] attribute to customize the JSON property name. There is a mention of issues with enums and datetime types. The need for documenting types is also discussed. Solution: It is suggested to test the code and try different approaches, like removing the JsonProperty decorators or using the "Date" string directly instead of nameOf().
unsoop
27 Sep, 2023, 05:10

no change

Drake
27 Sep, 2023, 17:31

Oh sorry I misunderstood...I thought you wanted it lowercase.

How about if you uncomment the JSON property and put "Date" string in there instead of nameOf()

unsoop
27 Sep, 2023, 18:59

sovled it!

unsoop
27 Sep, 2023, 18:59

and the github example is far from functional

unsoop
27 Sep, 2023, 19:00

and the github example is far from functional

unsoop
27 Sep, 2023, 19:00
Drake
27 Sep, 2023, 20:22

what do you mean?

unsoop
28 Sep, 2023, 17:35

a. the example shows only int and string and not more complicated data types like datetime.

b. there is no comment or document on what is the expected output for example my issue: this example is not showing that all keys will be lower cases unless the will serilize it like this:

var settings = new JsonSerializerSettings { ContractResolver = new DefaultContractResolver { NamingStrategy = null // Disable naming strategy } }; var jsondata = JsonConvert.SerializeObject(dataOut,settings);

Drake
28 Sep, 2023, 18:12

cc @Aditya Oberai, @VincentGe, thoughts?

unsoop
28 Sep, 2023, 18:14

just to credit myself, to this day i used appwrite with: http(rest),Go,Python,Flutter and using it from 0.7.0 just an FYI i felt like to write πŸ™‚

VincentGe
28 Sep, 2023, 18:17

why is everything being cast to lower case?

Aditya Oberai
28 Sep, 2023, 18:20

Will have to test this out once

cc: @Jake

Drake
28 Sep, 2023, 18:20

seems like it's something with dotnet's JSON serializer. is this type of stuff common knowledge?

unsoop
28 Sep, 2023, 18:20

im not that exprinced with C#, but looks like its default behavior

Drake
28 Sep, 2023, 18:21

sorry...more specifically for you is whether we need to document types. i actually just submitted a PR about datetime attribute

unsoop
28 Sep, 2023, 18:22

i think you should about every DB type. for example enum, i found out its looks as a string in the code

Drake
28 Sep, 2023, 18:24

what did you think it was going to be?

VincentGe
28 Sep, 2023, 18:24

πŸ€” Yeah this is actually possible now so we should totally do it!

unsoop
28 Sep, 2023, 18:25

not sure, as Enum is actule code extrapulation. *maby a bad example?

VincentGe
28 Sep, 2023, 18:25

Open an issue in Website

Drake
28 Sep, 2023, 18:26

but looks like its default behavior

btw, all of this stuff is transmitted as JSON and the common casing for JSON is camel case.

Similarly, in general, strings are common for datetime types. createdAt and updatedAt are strings (in JSON)

Aditya Oberai
28 Sep, 2023, 18:28

Yes, Newtonsoft.Json, the serialisation library we're using, by default converts PascalCase to camelCase

So normally if you need to customize the json property name for in any class whose objects are you be serialised, the [JsonProperty("propertyName")] attribute to customize the same

Drake
28 Sep, 2023, 18:29

thanks for the clarification πŸ™πŸΌ

unsoop
28 Sep, 2023, 18:29

my examples are also using this package

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more