From 88db90e01fc3bae7c6b8bc11aafaa71c8d16a3c8 Mon Sep 17 00:00:00 2001 From: Tommy Parnell Date: Wed, 11 Oct 2017 00:40:49 -0400 Subject: [PATCH] init --- Program.fs | 37 +++++++++++++++++++++++++++++++++++++ fjson.fsproj | 14 ++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 Program.fs create mode 100644 fjson.fsproj diff --git a/Program.fs b/Program.fs new file mode 100644 index 0000000..97f5c16 --- /dev/null +++ b/Program.fs @@ -0,0 +1,37 @@ +// Learn more about F# at http://fsharp.org + +open System +open Newtonsoft.Json +open System.Xml +open System.IO +type Tommy = + { + mutable Name: string + mutable Age: int + } +type Step() = + member val Name = "" with get,set + member val Age = 0 with get,set + + // { + // mutable Name: string + // mutable Desc: string + // } + +[] +let main argv = + let xml = " + Tommy + 27 + " + let serializer = System.Xml.Serialization.XmlSerializer(typeof); + use memory = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(xml)) + let rez = (serializer.Deserialize(memory) :?> Step) + printf "my name is %s and I'm %i" rez.Name rez.Age + let result = JsonConvert.DeserializeObject("{\"Name\": \"Tommy Parnell\", \"Age\": 27}") + if isNull(box result) + then + Console.WriteLine "its null" + else + printfn "my name is %s and my age is %i" result.Name result.Age + 0 // return an integer exit code diff --git a/fjson.fsproj b/fjson.fsproj new file mode 100644 index 0000000..3f6fcb3 --- /dev/null +++ b/fjson.fsproj @@ -0,0 +1,14 @@ + + + Exe + netcoreapp2.0 + + + + + + + + + + \ No newline at end of file