Question

Trying to parse a simple json string with the FSharp.Data.Json library and am faced with the following error. I am using F# 2.0 interactive. Any thoughts on how to go about solving the error

JsonValue.Parse(@"{""id"": ""117sds""}");;
System.MissingMethodException: Method not found: '!!0 Microsoft.FSharp.Collections.SeqModule.ExactlyOne(System.Collections.Generic.IEnumerable1<!!0>)'.
at FSharp.Data.Json.JsonParser..ctor(String jsonText, FSharpOption
1 culture)
at FSharp.Data.Json.JsonValue.Parse(String text, FSharpOption`1 culture) in C:\Tomas\Projects\FSharp.Data\src\Library\Json.fs:line 215
at .$FSI_0063.main@()

Was it helpful?

Solution

As Jack pointed out, the F# Data library really only works with F# 3.0. If you can update the F# version, it will work and you'll get other benefits (like type providers).

If you cannot upgrade then you can probably just copy the file with JSON parser and runtime to your project and change a few things to support F# 2.0 (the licence allows that). The file you need is Json.fs.

I don't think we'd want to support 2.0 version (so far), but if the fix is easy, submit a pull request with the change and we can merge that to make this easier for others.

OTHER TIPS

Seq.exactlyOne is a method which is only available in F# 3.0. Unfortunately, there's not going to be an easy way to use the FSharp.Data library from within F# 2.0.

As of version 1.1.6, the runtime components (Json parser, Csv parser and Http utilities) no longer use any method not present in FSharp.Core 4.0.0.0 (the F# 2.0 version), so you'll be able to use FSharp.Data with F# 2.0 if you don't use the type providers

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top