I need to serialize arbitrary records into maps/dictionary.
I imagine my end type look like this:
type TabularData= array<Map<string, obj>>
But I have problems in build a generic function that accept any record and turn them into Map.
I need to serialize arbitrary records into maps/dictionary.
I imagine my end type look like this:
type TabularData= array<Map<string, obj>>
But I have problems in build a generic function that accept any record and turn them into Map.
In practice, the best advice is probably to use some existing serialization library like FsPickler. However, if you really want to write your own serialization for records, then
GetRecordFields
(as mentioned in the comments) is the way to go.The following takes a record and creates a map from
string
field names toobj
values of the fields. Note that it does not handle nested records and it is not particularly fast:Here is a little example that calls this with a simple record: