You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there's a direct way with schematics to not only define models related to a JSON schema, but also specify how to populate it with data from another JSON schema?
For example, suppose I have a system with an internal schematics model specification, but I need to fetch data from a third-party service (or several) which gives me the data I need, but in a JSON satisfying a JSON schema of different structuring:
fields might have different names;
field values might have different formats;
internal fields might need to be inferred from multiple third-party fields;
fields, in any level of depth, might be represented in a flattened manner in one side and nested manner on the other;
Ex: {"weather_temperature": 75, "weather_wind": 100} as opposed to {"weather": {"temperature": 75, "wind": 100}}
third-party objects might need to be aggregated or disaggregated in order to fit the semantic of the internal schematics.
In the end, what I'm searching for is a simple, preferably declarative way to specify, for each of the fields present in my internal schematics representation, where is the related information present within a different schema, in a way that I'm able to simply feed the third-party JSON to my outer internal model's constructor.
The text was updated successfully, but these errors were encountered:
That's a complex requirement, you will need a mapper between two models for that.
Maybe you could achieve something close by having @serializable setters that implicitly set inner fields mapping from model1 to model2.
In a personal project I created a small DSL to convert between JSON structures, but I didn't require data validation there, although I could see a case where plugging a DSL to ingest data into a validator could make sense. But I feel this would be outside the scope of schematics itself.
Is there's a direct way with schematics to not only define models related to a JSON schema, but also specify how to populate it with data from another JSON schema?
For example, suppose I have a system with an internal schematics model specification, but I need to fetch data from a third-party service (or several) which gives me the data I need, but in a JSON satisfying a JSON schema of different structuring:
Ex:
{"weather_temperature": 75, "weather_wind": 100}
as opposed to{"weather": {"temperature": 75, "wind": 100}}
In the end, what I'm searching for is a simple, preferably declarative way to specify, for each of the fields present in my internal schematics representation, where is the related information present within a different schema, in a way that I'm able to simply feed the third-party JSON to my outer internal model's constructor.
The text was updated successfully, but these errors were encountered: