on 1.1.1.0 help sign in
69 lines 1.8 kB history raw
1{-# LANGUAGE RecordWildCards #-}
3{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
4{-# OPTIONS_GHC -fno-warn-orphans #-}
6module Compare.JsonBuilder () where
8import Prelude ()
9import Prelude.Compat
11import Data.Json.Builder
12import Data.Monoid ((<>))
13import Prelude hiding (id)
14import Twitter
16instance JsObject Metadata where
17 toObject Metadata{..} = row "result_type" result_type
19instance Value Metadata where
20 toJson = toJson . toObject
22instance JsObject Geo where
23 toObject Geo{..} =
24 row "type_" type_ <>
25 row "coordinates" coordinates
27instance Value Geo where
28 toJson = toJson . toObject
30instance Value a => Value (Maybe a) where
31 toJson (Just a) = toJson a
32 toJson Nothing = jsNull
34instance JsObject Story where
35 toObject Story{..} =
36 row "from_user_id_str" from_user_id_str <>
37 row "profile_image_url" profile_image_url <>
38 row "created_at" created_at <>
39 row "from_user" from_user <>
40 row "id_str" id_str <>
41 row "metadata" metadata <>
42 row "to_user_id" to_user_id <>
43 row "text" text <>
44 row "id" id_ <>
45 row "from_user_id" from_user_id <>
46 row "geo" geo <>
47 row "iso_language_code" iso_language_code <>
48 row "to_user_id_str" to_user_id_str <>
49 row "source" source
51instance Value Story where
52 toJson = toJson . toObject
54instance JsObject Result where
55 toObject Result{..} =
56 row "results" results <>
57 row "max_id" max_id <>
58 row "since_id" since_id <>
59 row "refresh_url" refresh_url <>
60 row "next_page" next_page <>
61 row "results_per_page" results_per_page <>
62 row "page" page <>
63 row "completed_in" completed_in <>
64 row "since_id_str" since_id_str <>
65 row "max_id_str" max_id_str <>
66 row "query" query
68instance Value Result where
69 toJson = toJson . toObject