我有这样的 JSON 格式的数据:
"members": [
"admin@test.com",
"user@test.com",
"guest_test.com@##internalservicedomain.test.com##"
]
我想添加角色:
admin is administrator
user is member
guest is guest
存储它的最佳方法是什么?
我可以这样做:
"members": [
{name: "admin@test.com", role: "administrator"},
{name: "user@test.com", role: "member"},
{name: "guest_test.com@##internalservicedomain.test.com##", role: "guest"}
]
或者像这样:
"members": [
"administrators": ["admin@test.com"],
"users": ["user@test.com"],
"guests: ["guest_test.com@##internalservicedomain.test.com##"]
]
但我不喜欢那些解决方案,有没有更简洁的方式来表示它?我更喜欢第一个选项,因为这样我可以更轻松地遍历元素,但是开销很糟糕,第二个选项看起来更好,但迭代起来似乎很复杂。