packages feed

json2sg (empty) → 0.0.1

raw patch · 7 files changed

+196/−0 lines, 7 filesdep +aesondep +basedep +bytestring

Dependencies added: aeson, base, bytestring, file-embed, hspec, json2sg, sugar, sugar-json, tasty, tasty-hspec, text

Files

+ CHANGELOG.md view
@@ -0,0 +1,5 @@+# Revision history for json2sg++## 0.1.0.0 -- YYYY-mm-dd++* First version. Released on an unsuspecting world.
+ LICENSE view
@@ -0,0 +1,14 @@+The BSD Zero Clause License (0BSD)++Copyright (c) 2022 Joe Vargas.++Permission to use, copy, modify, and/or distribute this software for any+purpose with or without fee is hereby granted.++THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH+REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY+AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,+INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM+LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR+PERFORMANCE OF THIS SOFTWARE.
+ README.md view
@@ -0,0 +1,75 @@+# json2sg++Lossy conversion from JSON to Sugar++#### Usage++Pass JSON through `stdin` and export out Sugar through `stdout`++```shell+json2sg < input.json > output.sg+```++## Format comparsion++JSON++```json+{+  "id": "62e32f511b845f8b3e1f577a",+  "index": 0,+  "quantity": 555.55,+  "guid": null,+  "isActive": false,+  "isExpired": true,+  "about": "Aliquip dolor adipisicing excepteur exercitation labore cupidatat non.",+  "tags": [+    "ex",+    "proident",+    "cupidatat"+  ],+  "nested": ["hello", ["world",	["!"]]],+  "assoc": [+    {+      "id": 0,+      "name": "duis"+    },+    {+      "id": 1,+      "name": "nisi"+    },+    {+      "id": 2,+      "name": "minim"+    }+  ]+}+```++Sugar++```racket+about "Aliquip dolor adipisicing excepteur exercitation labore cupidatat non."+assoc [+  {+    id 0+    name duis+  }+  {+    id 1+    name nisi+  }+  {+    id 2+    name minim+  }+]+guid ()+id 62e32f511b845f8b3e1f577a+index 0+isActive #f+isExpired #t+nested [hello (world [!])]+quantity 555.55+tags [ex proident cupidatat]+```
+ app/Main.hs view
@@ -0,0 +1,6 @@+module Main where++import qualified Sugar.Json.Convert++main :: IO ()+main = Sugar.Json.Convert.main
+ json2sg.cabal view
@@ -0,0 +1,64 @@+name: json2sg+version: 0.0.1+synopsis: Lossy conversion from JSON to Sugar+homepage: https://github.com/jxv/sugar#readme+description: Sugar is an alternative to: JSON, YAML, TOML, et cetera. Please see the README on GitHub at <https://github.com/jxv/sugar#readme>+category: Text, Configuration+bug-reports: https://github.com/jxv/sugar/issues+author: Joe Vargas+maintainer: Joe Vargas+license: OtherLicense+license-file: LICENSE+build-type: Simple+cabal-version: 2.0+extra-source-files:+    CHANGELOG.md+    LICENSE+    README.md++source-repository head+  type: git+  location: https://github.com/jxv/sugar++executable json2sg+  main-is: Main.hs+  default-language: Haskell2010+  hs-source-dirs:+      app+  build-depends:+      base >=4.7 && <5+    , json2sg-lib++library json2sg-lib+  exposed-modules:+      Sugar.Json.Convert+  hs-source-dirs:+      src+  default-extensions:+  ghc-options: -Wall+  build-depends:+      base >=4.7 && <5+    , bytestring >= 0.11 && <0.12+    , sugar == 0.0.1+    , sugar-json == 0.0.1.1+    , text+    , aeson+  default-language: Haskell2010++test-suite json2sg-tests+  type: exitcode-stdio-1.0+  main-is: Main.hs+  hs-source-dirs:+      tests+  ghc-options: -Wall -rtsopts -threaded -with-rtsopts=-N+  build-depends:+      base+    , file-embed+    , hspec+    , sugar+    , sugar-json+    , json2sg-lib+    , tasty+    , tasty-hspec+    , text+  default-language: Haskell2010
+ src/Sugar/Json/Convert.hs view
@@ -0,0 +1,19 @@+{-# LANGUAGE OverloadedStrings #-}+module Sugar.Json.Convert+  ( main+  ) where++import qualified Data.Aeson as Json+import qualified Data.ByteString.Lazy as LBS+import qualified Data.Text.IO as T+import System.IO (stdin, stderr, stdout)++import Sugar+import Sugar.Json () -- FromJSON Sugar instance++main :: IO ()+main = do+  contents <- LBS.hGetContents stdin+  case Json.decode' contents :: Maybe Sugar of+    Nothing -> T.hPutStrLn stderr "Unable to parse JSON"+    Just sg -> T.hPutStrLn stdout $ prettyPrintSugar sg
+ tests/Main.hs view
@@ -0,0 +1,13 @@+import qualified Test.Tasty+import Test.Tasty.Hspec+import Test.Hspec++main :: IO ()+main = do+    test <- testSpec "sugar" spec+    Test.Tasty.defaultMain test++spec :: Spec+spec = parallel $ do+    it "is trivially true" $ do+        True `shouldBe` True