Category
User level API features/changes
Describe the feature you'd like to request
I have tried to look into the apis provided and can't find a way to convert a JSON dynamically to an Entity.
Say I have the JSON object
{
"name": "John Doe",
"age": 55,
"is_staff": true,
"contacts": {
"email": "example@mail.com",
"phone": 98978
}
}
I would like to convert this to an Entities type with a function of maybe this signature
impl Entities {
pub fn from_payload(schema: &Schema, type: &str, payload: &[u8])-> Result<Self>
}
Expected entities representation (might be erroneous)
[
{
"uid": {
"type": "User",
"id": "..."
},
"attrs": {
"name": "John Doe",
"age": 55,
"is_staff": true,
"contacts": {
"type": "Contact",
"id": "444"
}
},
"parents": []
},
{
"uid": {
"type": "Contact",
"id": "444"
},
"attrs": {
"email": "example@mail.com",
"phone": 98978
},
"parents": []
}
]
It's not possible to write an own implementation since entityType is private to the crate consumer once parsed to the Schema type and also we wouldn't want to have different implementations in the wild.
Describe alternatives you've considered
I have tried to look into the apis provided for the Schema, Entities and can't find a way to convert a JSON dynamically to an Entities type.
Also, I haven't found any docs that describe this scenario.
Additional context
No response
Is this something that you'd be interested in working on?
Category
User level API features/changes
Describe the feature you'd like to request
I have tried to look into the apis provided and can't find a way to convert a JSON dynamically to an Entity.
Say I have the JSON object
{ "name": "John Doe", "age": 55, "is_staff": true, "contacts": { "email": "example@mail.com", "phone": 98978 } }I would like to convert this to an Entities type with a function of maybe this signature
Expected entities representation (might be erroneous)
[ { "uid": { "type": "User", "id": "..." }, "attrs": { "name": "John Doe", "age": 55, "is_staff": true, "contacts": { "type": "Contact", "id": "444" } }, "parents": [] }, { "uid": { "type": "Contact", "id": "444" }, "attrs": { "email": "example@mail.com", "phone": 98978 }, "parents": [] } ]It's not possible to write an own implementation since
entityTypeis private to the crate consumer once parsed to the Schema type and also we wouldn't want to have different implementations in the wild.Describe alternatives you've considered
I have tried to look into the apis provided for the
Schema,Entitiesand can't find a way to convert a JSON dynamically to an Entities type.Also, I haven't found any docs that describe this scenario.
Additional context
No response
Is this something that you'd be interested in working on?