Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 25 11:19
  • Jan 06 03:34
  • Dec 20 2019 07:46
    robkuz commented #81
  • Dec 02 2019 07:01
    adz opened #103
  • Sep 14 2019 03:56
  • Jul 09 2019 13:14
  • May 22 2019 14:12
  • Oct 10 2018 02:54
    Build #159 passed
  • Oct 10 2018 02:53

    panesofglass on master

    Setting minimum FSharp.Core to … Targeting minimum FSharp.Core 4… Merge pull request #100 from xy… and 7 more (compare)

  • Oct 10 2018 02:53
    panesofglass closed #102
  • Oct 10 2018 02:49
    Build #158 passed
  • Oct 10 2018 02:47
    panesofglass review_requested #102
  • Oct 10 2018 02:47
    panesofglass synchronize #102
  • Oct 10 2018 02:41
    panesofglass synchronize #102
  • Oct 10 2018 02:18
    panesofglass assigned #102
  • Oct 10 2018 02:18
    panesofglass opened #102
  • Oct 09 2018 14:01
    Build #157 passed
  • Oct 09 2018 13:56

    panesofglass on chiron-6

    Fix version in build.ps1 Add .editorconfig Generate documentation and 1 more (compare)

  • Oct 09 2018 13:56
    panesofglass closed #101
Alexander Prooks
@aprooks
but you will match on eventType and read properties accordingly
michaelcataldo
@michaelcataldo
Thanks for the help, I was hoping to find a way where I could use the FromJson method and json computation expressions on each of the event types and choose the type to deserialise into at runtime if that's at all possible...
@michaelcataldo this one works
michaelcataldo
@michaelcataldo
That's perfect! :smile: I wonder if the body of each match on eventType can be wrapped up into a function just to make things a little more stream lined but I think I'll be able to take it from here. Thanks again for the help.
Daniel J. Summers
@danieljsummers
I recently updated to .NET Core 2 and Chiron 7.0.0-alpha-170404, and my serialization from JSON isn't liking the types. I've checked all three branches, and I don't see the types that the UI and compiler seem to be seeing. I used to get an Object from the parsed JSON, but it seems that Json.parse is now returning either JPass or JError (also not in the source on GitHub), and the Object DU is defined as JsonObject instead of Map<string, Json>.
Here's the code that's not working any more...
  static member FromJson json =
    match Json.parse json with
    | Object config ->
        let options =
          config
          |> Map.toList
          |> List.map (fun item ->
              match item with
              | "Hostname", String x -> Hostname x
              | "Port",     Number x -> Port <| int x
              | "AuthKey",  String x -> AuthKey x
              | "Timeout",  Number x -> Timeout <| int x
              | "Database", String x -> Database x
              | key, value ->
                  raise <| InvalidOperationException
                             (sprintf "Unrecognized RethinkDB configuration parameter %s (value %A)" key value))
        { Parameters = options }
    | _ -> { Parameters = [] }
The error:
error FS0001: Type mismatch. Expecting a
    'JsonResult<Json> -> Choice<'a,'b,'c,'d,'e,'f>'    
but given a
    'Json -> Choice<JsonObject,Json list,string,string,bool,unit>'    
The type 'JsonResult<Json>' does not match the type 'Json'
I can change Object config to JPass config, but then I get a JsonObject that doesn't like being fed into Map.toList.
Daniel J. Summers
@danieljsummers
I moved back to 6.3.0-rc1, and it seems to build and run under .NET Core 2. I'll just move forward with that and update the dependency later. :)
Alexander Battisti
@battisti

Hi, I seem to have a similar problem as @danieljsummers using .NET Core and Chrion 7.0.0-alpha e.g.

open Chiron
open Chiron.Operators

let t1 = Object (Map.ofList [ "bool", Bool true ])

result in an (first is for the Bool, second for the Object):

This value is not a function and cannot be applied.
This expression was expected to have type 'JsonObject' but here has type 'Map<string,'a>'

The compiler also seems not to be able to find the Json.write function, any suggestions?

Florian Verdonck
@nojaf

Hi, I'm trying a basic scenario with Chiron inside a script file. I have:

#r "./packages/Chiron/lib/portable-net45+netcore45+wpa81+wp8+MonoAndroid1+MonoTouch1/Chiron.dll"
#r "./packages/Aether/lib/netstandard1.6/Aether.dll"

open Aether
open Chiron

let item = 
    """
    {
        name:"Florian",
        age:27,
        city:"Ghent"
    }
    """

type Person = {
    Name:string
    Age:int
    City:string
} 

type Person with
  static member ToJson (x:Person) = json {
      do! Json.write "name" x.Name
      do! Json.write "age" x.Age
      do! Json.write "city" x.City
  }

When executing I receive: error FS0074: The type referenced through 'Aether.Prism2' is defined in an assembly that is not referenced. You must add a reference to assembly 'Aether'.`

What could I be missing here?
Dustin Lacewell
@dustinlacewell
@battisti @danieljsummers I spent hours looking at the code for the 7.0 alpha and things have changed a bit
And here is the actual pull request, xyncro/chiron#81
I am deserializing things like:
    static member FromJson(_:Link) =
        jsonDecoder {
            let! rel = D.required D.string "rel"
            let! url = D.required D.string "href"
            return Link.Create rel url }
And serializing them like:
    static member ToJson(x:Link) =
        E.required E.string "rel" x.Rel >>
        E.required E.string "href" x.Href
I have not figured out how to utilize the new json {} builder and would appreciate some help in this regard!
Daniel J. Summers
@danieljsummers
Thanks for the example. :) I hope to circle back to that project early Q1 2018.

From looking at the documentation in that PR, do you think serialization might work something like

static member ToJson(x:Link) =
    json {
        do! E.required E.string "rel" x.Rel
        do! E.required E.string "href" x.Href }

? (speculating)

Dustin Lacewell
@dustinlacewell
@danieljsummers tried that it doesn't work
Dustin Lacewell
@dustinlacewell
@danieljsummers
    static member Encode(x:Link) jObj =
        jObj
        |> E.required E.string "rel" x.Rel
        |> E.required E.string "href" x.Href
static member ToJson(x:Link) jObj = Encode
This way you can refer to the encoder and get inferred encoding
Daniel J. Summers
@danieljsummers
Ah - thanks!
Rob Kayman
@rkayman
Noob question. Why when I serialize do the properties of the object appear in reverse order? Is there a way to alter that behavior?
btrepp
@btrepp
@rkayman are they reverse? I alway suspected they came out alphabetically, most likely to due to it being a Map<string,Json> for an object
Rob Kayman
@rkayman
@btrepp You are correct. It so happens my trial case had - quite coincidentally - the fields listed in reverse alphabetical order. Any work arounds for the output to match the order of the input?
btrepp
@btrepp
Not sure really, My guess is that the order is somewhat lost with Map.add and then iterating that. Is there are reason order is important?. In JSON itself order is not meant to be important, so you might be searching for a different serializing strategy if it is?
Rob Kayman
@rkayman
It's true whether serializing to XML or JSON or even CSV - order of the fields shouldn't matter, and to us it doesn't. But to those testing... well, they get a little flipped out and begin to wonder about the quality or veracity of the results. Seems like it should only take a moment to relate the alphabetical ordering; however, if it's an unexpected behavior and you (me) can't explain it immediately... then their reaction is different. I think we can write this one up to just being aware of the expected behavior so we (I) don't get caught off guard. Thanks!
btrepp
@btrepp
Ah well I am pretty confident that its because of Map.add and such, the only reason I was vague is perhaps there is a way of using options to formatter (or walking the AST yourself and writing the order you would like) :)
btrepp
@btrepp
Also, glad to hear you werent talking to some other server that expected specific ordered json. That seems terrifying :)
Rob Kayman
@rkayman
🤔hmm, walking the AST might be interesting. Would definitely get me familiar with code base and I've been thinking/toying with the idea of a "Chiron for XML" just for kicks. Thanks for the idea!
btrepp
@btrepp
If chiron for XML becomes a thing keep me posted, After using chiron I can't go back to other kinds of serializers, and have been thinking about the same thing. I wholesale ripped of the idea of building an AST for html, but its not quality enough to share yet
Josselin Auguste
@josselinauguste
I see that Chiron is able to encode/decode datetimes but not dates, is it by design or an oversight?
btrepp
@btrepp
@josselinauguste, I'd say its just what was implemented out of the box. There is a whole heap of different kinds of BCL objects, so I can't imagine you would want them all.
Tbh I'd even say including System.DateTime is a mistake :)
but I exclusively use NodaTime in my apps
mtnrbq
@mtnrbq
Hi - I'm just starting to try and use Chiron to deal with a Json api I am not in control of. However, I'm wondering if I'm missing something
I've followed the blog posts, and implemented some of the beghaviour I need
My question is - are there any 'shortcut' utilities to , for example, take a series of properties at a particular level and just push them into a dictionary property on a record when de-serializing?
(the json I'm consuming has a lot of properties at various levels that i would like, but don;t need as discrete fields)
Josselin Auguste
@josselinauguste
@btrepp ok I understand, even if i’m convinced that date and datetime are primitives which are so used that it makes sense to include them :-)
by the way adding support for date took me just a few lines, so no big deal :+1:
btrepp
@btrepp
@mtnrbq . The chiron Json object is essentially a recursive map (its type is Map<string,Json>)
Julian DeMille
@jdemilledt
@btrepp How would one go about accessing that data? My linter is telling me that the .[] notation is invalid for Json
btrepp
@btrepp
@jdemilledt . Pattern matching! :)
open Chiron
let myobject : Json = ["hello", Json.String "world"] |> Map.ofList |> Json.Object

let worldstring = match myobject with
                                   | Json.Object m -> Map.tryFind "hello" m
                                   | Json.String _ -> None
                                   | _ -> None /*etc etc */
Aaron Muylaert
@aaronmu
I've seen lots of examples that use the Json.read function, however, I can't seem to find that function anywhere? Was Json.read removed?