f#-data

Can JsonProvider deserialise to a Generic.Dictionary?

安稳与你 提交于 2021-01-27 08:07:52
问题 I'm learning about type providers and it looks like a ground breaking feature. However, I can't manage to deserialise json with JsonProvider so that the target type has a Generic.Dictionary property. It can be done with Json.NET. Here is the code: type ByProv = JsonProvider<"""{"dict":{"A":1,"B":2}}"""> type ByHand(d:Dictionary<string,int>) = member val dict = d with get,set let text = """{"dict":{"C":3,"D":4}}""" let newt = JsonConvert.DeserializeObject<ByHand> text let prov = ByProv.Parse

Can JsonProvider deserialise to a Generic.Dictionary?

送分小仙女□ 提交于 2021-01-27 07:58:49
问题 I'm learning about type providers and it looks like a ground breaking feature. However, I can't manage to deserialise json with JsonProvider so that the target type has a Generic.Dictionary property. It can be done with Json.NET. Here is the code: type ByProv = JsonProvider<"""{"dict":{"A":1,"B":2}}"""> type ByHand(d:Dictionary<string,int>) = member val dict = d with get,set let text = """{"dict":{"C":3,"D":4}}""" let newt = JsonConvert.DeserializeObject<ByHand> text let prov = ByProv.Parse

Can JsonProvider deserialise to a Generic.Dictionary?

时光毁灭记忆、已成空白 提交于 2021-01-27 07:58:25
问题 I'm learning about type providers and it looks like a ground breaking feature. However, I can't manage to deserialise json with JsonProvider so that the target type has a Generic.Dictionary property. It can be done with Json.NET. Here is the code: type ByProv = JsonProvider<"""{"dict":{"A":1,"B":2}}"""> type ByHand(d:Dictionary<string,int>) = member val dict = d with get,set let text = """{"dict":{"C":3,"D":4}}""" let newt = JsonConvert.DeserializeObject<ByHand> text let prov = ByProv.Parse

F#.Data HTML Parser Extracting Strings From Nodes

我的梦境 提交于 2021-01-01 04:43:15
问题 I am trying to use FSharp.Data's HTML Parser to extract a string List of links from href attributes. I can get the links printed out to console, however, i'm struggling to get them into a list. Working snippet of a code which prints the wanted links: let results = HtmlDocument.Load(myUrl) let links = results.Descendants("td") |> Seq.filter (fun x -> x.HasClass("pagenav")) |> Seq.map (fun x -> x.Elements("a")) |> Seq.iter (fun x -> x |> Seq.iter (fun y -> y.AttributeValue("href") |> printf "%A

Code coverage using dotCover throws an error - FAKE F#MAKE

血红的双手。 提交于 2020-01-25 21:26:28
问题 I am trying to use DotCover in FAKE , but it is throwing some error , as I am new to FAKE as well as F# , it's becoming difficult for me to understand the root cause of the problem . Here is the code : #r "D:/FAKEProject/Fake/packages/FAKE/tools/FakeLib.dll" open Fake open Fake.DotCover let testDir = "D:/FAKEProject/Fake/test/" let filters = "" Target "Clean" (fun _ -> CleanDirs [testDir] ) Target "TestCoverage" (fun _ -> !! ("D:/FAKEProject/Fake/UnitTest/UnitTest.dll") |> DotCoverNUnit (fun

Why am I getting F# error FS0039: The namespace or module 'Http' is not defined

与世无争的帅哥 提交于 2020-01-15 03:46:09
问题 In Visual Studio 2015 and 2017, I'm trying out the Http class from several F# examples in FSharp Interactive, and I keep getting: error FS0039: The namespace or module 'Http' is not defined Here's the sample: open FSharp.Data let response = Http.RequestString("http://api.themoviedb.org/3/search/movie", silentHttpErrors = true) This is clearly due to the version of FSharp.Data. Is there a way to specify the correct version for FSharp Interactive? What version of FSharp.Data contains the Http

F# TypeProvider “XMLProvider” gives System.Exception

六眼飞鱼酱① 提交于 2020-01-14 10:35:09
问题 I'm trying to process Twitter tweets using the XML type provider as represented by the code below. The code works fine when accessing tweet data values using LINQ XElement functions, however it fails with an exception saying: “XML mismatch: Expected exactly one 'title' child”, when using the type created by the XMLProvider. I know namespaces are not given, however, I don't know how they would be specified with the provider, if they're needed. // ... open FSharp.Net open FSharp.Data let ns =

Changing an immutable object F#

南笙酒味 提交于 2020-01-10 19:13:07
问题 I think the title of this is wrong but can't create a title that reflects, in the abstract, what I want to achieve. I am writing a function which calls a service and retrieves data as a JSON string. The function parses the string with a JSON type provider. Under certain conditions I want to amend properties on that JSON object and then return the string of the amended object. So if the response from the call was {"property1" : "value1","property2" : "value2", "property3": "value3" } I want to

Why do I get a missing method exception runtime when creating a SqlClient type?

谁说胖子不能爱 提交于 2020-01-03 17:04:34
问题 I have the following code: open FSharp.Data [<Literal>] let connectionString = @"Data Source=(local)\SQLExpress;Integrated Security=SSPI;Database=SfagStage" type InsertEnhet = SqlCommandProvider<"Sql\InsertEnhet.sql", connectionString> let insertEnhet (enhet:Enhet) = let cmd = new InsertEnhet() // <<--- This generates an error runtime cmd.Execute(enhet.Navn, enhet.Enhetsnummer, enhet.LEIKode, enhet.Kommune, DateTime.Now) The row where I create the command is what causing the missing method I

Using F# JsonProvider within a portable class library fails

风格不统一 提交于 2020-01-02 07:30:56
问题 I'm trying to use the JsonProvider and I'm getting the following error when I call a function on it: System.TypeInitializationException was unhandled Message: An unhandled exception of type 'System.TypeInitializationException' occurred in PortableLibrary1.dll Additional information: The type initializer for '<StartupCode$PortableLibrary1>.$PortableLibrary1' threw an exception. I have a basic console application as follows: module Pinit = open FSharp.Data type JsonT = JsonProvider<"""..\myFile