-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
finish first version of json io functions
- Loading branch information
Showing
16 changed files
with
240 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
namespace FsSpreadsheet.Js | ||
|
||
open FsSpreadsheet | ||
open Fable.ExcelJs | ||
open Fable.Core | ||
open Fable.Core.JsInterop | ||
open Fable.Core.JS | ||
|
||
open Thoth.Json.JavaScript | ||
|
||
|
||
|
||
|
||
/// This does currently not correctly work if you want to use this from js | ||
/// https://github.com/fable-compiler/Fable/issues/3498 | ||
[<AttachMembers>] | ||
type Json = | ||
|
||
static member fromJsonString (json:string) : FsWorkbook = | ||
match Thoth.Json.JavaScript.Decode.fromString FsSpreadsheet.Json.Workbook.decode json with | ||
| Ok wb -> wb | ||
| Error e -> failwithf "Could not deserialize json Workbook: \n%s" e | ||
|
||
static member toJsonString (wb:FsWorkbook, ?spaces) : string = | ||
let spaces = defaultArg spaces 2 | ||
FsSpreadsheet.Json.Workbook.encode wb | ||
|> Thoth.Json.JavaScript.Encode.toString spaces | ||
|
||
//static member fromJsonFile (path:string) : Promise<FsWorkbook> = | ||
// promise { | ||
// let! json = Fable.Core.JS. path | ||
// return Json.fromJsonString json | ||
// } | ||
|
||
//static member toJsonFile (path:string) (wb:FsWorkbook) : Promise<unit> = | ||
// let json = Json.toJsonString wb | ||
// Fable.Core.JS.writeFile path json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.