I can't understand why this
let data =
JsonConvert.DeserializeObject<Dictionary<string, Dictionary<string, string>>>(
File.ReadAllText <| Path.Combine(myPath, "ejv.json"))
is ok, while this
let data =
JsonConvert.DeserializeObject<Dictionary<string, Dictionary<string, string>>>
<| File.ReadAllText
<| Path.Combine(myPath, "ejv.json")
Gives me two errors, first is:
and second is:
What did I do wrong?
UPDATE @Patryk Ćwiek suggested a good edit, which seems to fix errors with types:
let data = JsonConvert.DeserializeObject<Dictionary<string, Dictionary<string, string>>>
<< File.ReadAllText
<| Path.Combine(myPath, "ejv.json")
But it produces another puzzling message: Unexpected type arguments. Here's a screenshot:
I can easily get rid of it removing <Dictionary<string, Dictionary<string, string>>>
but in this case my data is of object
type, not a Dictionary
. Can I somehow save type information an use pipelining as well?
SOLUTION
Thanks to @Patryk Ćwiek solution is as follows:
let d<'a>(s:string) = JsonConvert.DeserializeObject<'a>(s)
let data =
Path.Combine(myPath, "ejv.json")
|> File.ReadAllText
|> d<Dictionary<string, Dictionary<string, string>>> with
I don't know why, but without that alias d
it doesn't work.