Given the code:
#if INTERACTIVE
#r "bin\Debug\FSharp.Data.dll"
#endif
open System
open FSharp.Data
open FSharp.Data.Json
let testJson = """{ "workingDir":"hello", "exportDir":"hi there", "items":[{ "source":"", "dest":"", "args": {"name":"that"} }] }"""
//here is where i get the error
let Schema = JsonProvider<testJson>
The last line keeps giving me the error "This is not a constant expression or valid custom attribute value"-- what does that mean? How can i get it to read this JSON?
The string has to be marked as a constant. To do that, use the [<Literal>]
attribute. Also, the type provider creates a type, not a value, so you need to use type
instead of let
:
open FSharp.Data
[<Literal>]
let testJson = """{ "workingDir":"hello", "exportDir":"hi there", "items":[{ "source":"", "dest":"", "args": {"name":"that"} }] }"""
type Schema = JsonProvider<testJson>
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