packages feed

json-autotype 0.2.1.3 → 0.2.1.4

raw patch · 3 files changed

+73/−1 lines, 3 files

Files

README.md view
@@ -35,3 +35,70 @@ You may either edit the resulting file _and_ send it to the author as a test case for future release.  Patches and suggestions are welcome.++EXAMPLES:+=========++The most simple example:+```+    {+        "colorsArray":[{+                "colorName":"red",+                "hexValue":"#f00"+            },+            {+                "colorName":"green",+                "hexValue":"#0f0"+            },+            {+                "colorName":"blue",+                "hexValue":"#00f"+            }+        ]+    }+```++It will produce the module with the following datatypes and TH calls for JSON parser derivations:+```+    data ColorsArray = ColorsArray {+        colorsArrayHexValue    :: Text,+        colorsArrayColorName :: Text+      } deriving (Show,Eq)++    data TopLevel = TopLevel {+        topLevelColorsArray :: ColorsArray+      } deriving (Show,Eq)+```+Note that attribute names match the names of JSON dictionary keys.++Another example with ambiguous types:+```+    {+        "parameter":[{+                "parameterName":"apiVersion",+                "parameterValue":1+            },+            {+                "parameterName":"failOnWarnings",+                "parameterValue":false+            },+            {+                "parameterName":"caller",+                "parameterValue":"site API"+            }]+    }+```+It will produce quite intuitive result (plus extra parentheses, and class derivations):++```+    data Parameter = Parameter {+        parameterParameterValue :: Either Bool (Either Int Text),+        parameterParameterName :: Text+      }++    data TopLevel = TopLevel {+        topLevelParameter :: Parameter+      }+```++Real-world use case examples are provided in the package [source repository](https://github.com/mgajda/json-autotype/tree/master/test).
changelog.md view
@@ -1,6 +1,10 @@ Changelog ========= +    0.2.1.4  Oct 2014++        * Added examples to the package distribution.+     0.2.1.3  Oct 2014          * Cleaned up package.
json-autotype.cabal view
@@ -1,6 +1,6 @@ -- Build information for the package. name:                json-autotype-version:             0.2.1.3+version:             0.2.1.4 synopsis:            Automatic type declaration for JSON input data description:         Generates datatype declarations with Aeson's "FromJSON" instances                      from a set of example ".json" files.@@ -23,6 +23,7 @@ homepage:            https://github.com/mgajda/json-autotype license:             BSD3 license-file:        LICENSE+stability:           beta author:              Michal J. Gajda maintainer:          mjgajda@gmail.com copyright:           Copyright by Michal J. Gajda '2014