Sorry if this question is a bit unclear. It was the best I could do in my state of confusion about packages in F# 4.0.
The book Expert F# 4.0
by Don Syme, Adam Granicz, and Antonio Cisternino contains code that processes JSON data. The code starts with
open FSharp.Data
open FSharp.Data.JsonExtensions
I have FSharp.Data
installed in Visual Studio. Still, the word "JsonExtensions" gets red squiggles under it and the rest of the code does not compile.
Going to Add References
in the Solution Explorer I did not find a package FSharp.Data.JsonExtensions
. I also looked under NuGet
and found no package FSharp.Data.JsonExtensions
. There is documentation for JsonExtensions
which suggests it is a module. However, using the dot in Visual Studio it does not appear under FSharp.Data.
(There is only one entry: Unit Systems
)
How can I make the code in this module available so I can run the code in the book?
This happens because actually you don't have FSharp.Data installed (So Foggy is right above). There is an FSharp.Data namespace but you need to nuget the package to be able to use it. So go to Tools | Nuget Package Manager | Manage Nuget Packages for Solution
and download the latest and greatest FSharp.Data
. This will automatically add it to your references file in VS:
See:
Now you can use it:
If you are using it from an .fsx script make sure to reference it with #r
#r @"..\packages\FSharp.Data.2.3.2\lib\net40\FSharp.Data.dll"
In that case you can just right-click on the References (after nugetting) and VS will generate you the path:
If you don't see Send to F# Interactive
I strongly suggest you install the Visual F# Power Tools.
You can explore other ways of accessing/serializing JSON files: there is the JSON type provider, Newtonsoft JSON, FSharplu, Chiron, and FSPickler.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With