Back

Can Appwrite support creating a field that stores an array of JSON objects within a document?

  • 0
  • Web
  • Cloud
Nana
10 Jan, 2025, 10:06

I'm trying to store an attribute in my document that contains an array of objects (JSON). Each object has multiple properties like name, email, and locked. For example:

TypeScript
{
  "students": [
    { "name": "John", "email": "john@example.com", "locked": false },
    { "name": "Jane", "email": "jane@example.com", "locked": true }
  ]
}

I am currently using Appwrite for my project, and I want to confirm if it's possible to store an array of objects (JSON) in a field. If this isn't supported, what would be the best way to structure this kind of data within Appwrite?

TL;DR
Appwrite does not directly support storing an array of JSON objects within a document. A workaround is to stringify the objects, store them as strings, and mark the attribute as an array.
Darshan Pandya
10 Jan, 2025, 10:45

stringify your objects and save as strings.

Darshan Pandya
10 Jan, 2025, 10:46

if its an array, split items, stringify and save to a string attribute but mark it as an array

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