@@ -0,0 +1,65 @@
1+{-# LANGUAGE RecordWildCards #-}
2+{-# OPTIONS_GHC -fno-warn-orphans #-}
4+module Compare.JsonBuilder () where
6+import Data.Json.Builder
7+import Data.Monoid ((<>))
8+import Prelude hiding (id)
10+import Twitter.Manual ()
12+instance JsObject Metadata where
13+ toObject Metadata{..} = row "result_type" result_type
15+instance Value Metadata where
16+ toJson = toJson . toObject
18+instance JsObject Geo where
21+ row "coordinates" coordinates
23+instance Value Geo where
24+ toJson = toJson . toObject
26+instance Value a => Value (Maybe a) where
27+ toJson (Just a) = toJson a
28+ toJson Nothing = jsNull
30+instance JsObject Story where
32+ row "from_user_id_str" from_user_id_str <>
33+ row "profile_image_url" profile_image_url <>
34+ row "created_at" created_at <>
35+ row "from_user" from_user <>
36+ row "id_str" id_str <>
37+ row "metadata" metadata <>
38+ row "to_user_id" to_user_id <>
41+ row "from_user_id" from_user_id <>
43+ row "iso_language_code" iso_language_code <>
44+ row "to_user_id_str" to_user_id_str <>
47+instance Value Story where
48+ toJson = toJson . toObject
50+instance JsObject Result where
51+ toObject Result{..} =
52+ row "results" results <>
53+ row "max_id" max_id <>
54+ row "since_id" since_id <>
55+ row "refresh_url" refresh_url <>
56+ row "next_page" next_page <>
57+ row "results_per_page" results_per_page <>
59+ row "completed_in" completed_in <>
60+ row "since_id_str" since_id_str <>
61+ row "max_id_str" max_id_str <>
64+instance Value Result where
65+ toJson = toJson . toObject