-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic document mapping #18
Comments
Legivel Mapper currently does not support the mapping to But you can start anyway, You can have a look in this source, and check for |
Aha, got it: The thing that I'm not quite familiar with is how to invoke my particular mapping for my type. Let's say that for the above case ( type InvokeFunc = { funcName: string; argument: string option } So my type then is a Record and I should then somehow push that into |
I was thinking of creating a custom type You can then make a function like: type MyTarget = {
a_func: ParamList
b_func: ParamList
c_func: ParamList
} The Custom Mapper can detect whether it is type I think in this case it would be wise to put your custom mapper first, to not confuse it with the generic types. Maybe you only need to re-create this function. There is one "but" in this process. I've been hiding quite a lot of data and funcs to improve dev-experience (including my own), and I've found that I've been a bit too enthousiastic doing this... |
I too would love the ability to simply use |
I hope I understand your question correctly. The Yaml Parser provides functionality to convert yaml text to a generic internal representation. The Yaml Mapper, maps the generic format to a specific Type. So if you want to intervene between parser and mapper, you must look at the mapper entry function here, with special attention to Function You should be able to create your own custom implementation with this info - assuming I understand your question correctly. |
Thanks. Unfortunately I am unable to divine those implementation details (or at least undocumented parts of the API) from the source code, and I don't see how I can adapt my code to support this. In any case, deserializing directly to a dynamic Another alternative would be to just convert from YAML to JSON and use System.Text.Json. |
In my case, the need is even simpler. Some kind of intermediate type would be great. |
I tried adding This sort of strikes me as odd for a yaml library, because yaml by design is supposed to be written by humans, and humans aren't strict about conforming exactly to types. |
I'm trying to parse some real world manually written documents with some type inconsistencies:
In this case there are just one or two fields like this in otherwise very large documents, so Legivel technically gets me to 99% of my task except for this specific case.
Would it be somehow possible to tell Legivel to map such values into some sort of parsed abstract document, like:
Or optionally let users provide custom constructors:
Sorry for bugging you so much. It seems I'm trying to push Legivel into places it hadn't been intended to for. I've been looking at other Yaml libraries for dotnet, but none have proper support for F# discriminated unions.
The text was updated successfully, but these errors were encountered: