Encoders and Decoders for JSON that goes over the wire.
You will rarely use any of these. Encoding and decoding will usually
be done for you by by Mastodon.Requests.requestToRawRequest
, which
your code will call indirectly via Mastodon.Requests.serverRequest
.
encodeEntity : Mastodon.Entity.Entity -> Json.Encode.Value
Encode an Entity
into a Value
.
entityDecoder : String -> Json.Decode.Decoder Mastodon.Entity.Entity
Decode an Entity
.
You'll usually know which entity you're looking for, and will use its decoder explicitly. In case you don't...
The urlString is used only to decode an Instance. It is used to default fields when the server returns {} (which it shouldn't, but some do).
entityValue : Mastodon.Entity.Entity -> Json.Encode.Value
Similar to encodeEntity
, but returns the v
field, if it is non-null,
giving you the raw data that came over the wire, if this entity DID come over
the wire, and is not one of the few that don't have a v
field.
accountDecoder : Json.Decode.Decoder Mastodon.Entity.Account
Decode an Account
.
encodeAccount : Mastodon.Entity.Account -> Json.Encode.Value
Encode an Account
.
fieldDecoder : Json.Decode.Decoder Mastodon.Entity.Field
Decode a Field
.
encodeField : Mastodon.Entity.Field -> Json.Encode.Value
Encode a Field
.
appDecoder : Json.Decode.Decoder Mastodon.Entity.App
Decode an App
.
encodeApp : Mastodon.Entity.App -> Json.Encode.Value
Encode an App
.
sourceDecoder : Json.Decode.Decoder Mastodon.Entity.Source
Decode a Source
.
encodeSource : Mastodon.Entity.Source -> Json.Encode.Value
Encode a Source
.
tokenDecoder : Json.Decode.Decoder Mastodon.Entity.Token
Decode a Token
.
encodeToken : Mastodon.Entity.Token -> Json.Encode.Value
Encode a Token
.
applicationDecoder : Json.Decode.Decoder Mastodon.Entity.Application
Decode an Application
.
encodeApplication : Mastodon.Entity.Application -> Json.Encode.Value
Encode an Application
.
attachmentDecoder : Json.Decode.Decoder Mastodon.Entity.Attachment
Decode an Attachment
.
encodeAttachment : Mastodon.Entity.Attachment -> Json.Encode.Value
Encode an Attachment
.
cardDecoder : Json.Decode.Decoder Mastodon.Entity.Card
Decode a Card
.
encodeCard : Mastodon.Entity.Card -> Json.Encode.Value
Encode a Card
.
contextDecoder : Json.Decode.Decoder Mastodon.Entity.Context
Decode a Context
.
encodeContext : Mastodon.Entity.Context -> Json.Encode.Value
Encode a Context
.
visibilityDecoder : Json.Decode.Decoder Mastodon.Entity.Visibility
Decode a Visibility
.
encodeVisibility : Mastodon.Entity.Visibility -> Json.Encode.Value
Encode a Visibility
.
emojiDecoder : Json.Decode.Decoder Mastodon.Entity.Emoji
Decode an Emoji
.
encodeEmoji : Mastodon.Entity.Emoji -> Json.Encode.Value
Encode an Emoji
.
encodeStatus : Mastodon.Entity.Status -> Json.Encode.Value
Encode a Status
.
statusDecoder : Json.Decode.Decoder Mastodon.Entity.Status
Decode a Status
.
This integrates the non-standard fields, so that you can just use content
for the full HTML to actually display.
encodeStatusSource : Mastodon.Entity.StatusSource -> Json.Encode.Value
Encode a StatusSource
statusSourceDecoder : Json.Decode.Decoder Mastodon.Entity.StatusSource
Decode a StatusSource
rawStatusDecoder : Json.Decode.Decoder Mastodon.Entity.RawStatus
Decode a RawStatus
.
simpleStatusDecoder : Json.Decode.Decoder Mastodon.Entity.Status
Just decode the fields that are supported by all servers.
The content
field means different things on some servers, so use
statusDecoder
if you want it to have the full HTML for the post.
canFailStatusDecoder : Json.Decode.Decoder Mastodon.Entity.Status
Same as statusDecoder
, except if it fails, falls back to a
mostly defaulted Status
, with only the id
, uri
, url
, and
account
fields filled in.
The content
property will be:
"*** This status was malformed, id: <id> ***"
encodeHistoryStatus : Mastodon.Entity.HistoryStatus -> Json.Encode.Value
Encode a HistoryStatus
historyStatusDecoder : Json.Decode.Decoder Mastodon.Entity.HistoryStatus
Decode a HistoryStatus
.
encodeError : Mastodon.Entity.Error -> Json.Encode.Value
Encode an Error
.
Note that the httpStatus
field does NOT get encoded.
You'll probably never need to encode one of these, anyway.
errorDecoder : String -> Json.Decode.Decoder Mastodon.Entity.Error
Decode an Error
.
Since the httpStatus
comes from the HTTP headers, it needs to be
passed in here as a parameter, as it isn't in the JSON.
encodePoll : Mastodon.Entity.Poll -> Json.Encode.Value
Encode a Poll
.
pollDecoder : Json.Decode.Decoder Mastodon.Entity.Poll
Decode a Poll
.
encodePollDefinition : Mastodon.Entity.PollDefinition -> Json.Encode.Value
Encode a PollDefinition
.
pollDefinitionDecoder : Json.Decode.Decoder Mastodon.Entity.PollDefinition
Decode a PollDefinition
.
encodeFilter : Mastodon.Entity.Filter -> Json.Encode.Value
Encode a Filter
.
filterDecoder : Json.Decode.Decoder Mastodon.Entity.Filter
Decode a Filter
.
encodeFilterContext : Mastodon.Entity.FilterContext -> Json.Encode.Value
Encode a FilterContext
.
filterContextDecoder : Json.Decode.Decoder Mastodon.Entity.FilterContext
Decode a FilterContext
.
encodeInstance : Mastodon.Entity.Instance -> Json.Encode.Value
Encode an Instance
.
instanceDecoder : String -> Json.Decode.Decoder Mastodon.Entity.Instance
Decode an Instance
.
defaultedInstance : String -> Json.Encode.Value -> Mastodon.Entity.Instance
Return the default instance for a URL string.
Used for servers that return a malformed Instance or no JSON at all.
encodeActivity : Mastodon.Entity.Activity -> Json.Encode.Value
Encode an Activity
.
Mastodon encodes all the Int
fields as strings, so we follow suit here.
Pleroma and Gab don't support "GET instance/activity".
activityDecoder : Json.Decode.Decoder Mastodon.Entity.Activity
Decode an Activity
encodeListEntity : Mastodon.Entity.ListEntity -> Json.Encode.Value
Encode a ListEntity
.
listEntityDecoder : Json.Decode.Decoder Mastodon.Entity.ListEntity
Decode a ListEntity
.
encodeNotification : Mastodon.Entity.Notification -> Json.Encode.Value
Encode a Notification
.
notificationDecoder : Json.Decode.Decoder Mastodon.Entity.Notification
Decode a Notification
.
encodeNotificationType : Mastodon.Entity.NotificationType -> Json.Encode.Value
Encode a NotificationType
.
notificationTypeDecoder : Json.Decode.Decoder Mastodon.Entity.NotificationType
Decode a `NotificationType.
encodePushSubscription : Mastodon.Entity.PushSubscription -> Json.Encode.Value
Encoder for PushSubscription
.
pushSubscriptionDecoder : Json.Decode.Decoder Mastodon.Entity.PushSubscription
Decoder for PushSubscription
.
encodeRelationship : Mastodon.Entity.Relationship -> Json.Encode.Value
Encoder for Relationship
.
relationshipDecoder : Json.Decode.Decoder Mastodon.Entity.Relationship
Decode a Relationship
.
encodeResults : Mastodon.Entity.Results -> Json.Encode.Value
Encoder for Results
.
resultsDecoder : Json.Decode.Decoder Mastodon.Entity.Results
Decoder for Results
.
encodeScheduledStatus : Mastodon.Entity.ScheduledStatus -> Json.Encode.Value
Encoder for ScheduledStatus
.
scheduledStatusDecoder : Json.Decode.Decoder Mastodon.Entity.ScheduledStatus
Decoder for ScheduledStatus
.
encodeConversation : Mastodon.Entity.Conversation -> Json.Encode.Value
Encoder for Conversation
.
conversationDecoder : Json.Decode.Decoder Mastodon.Entity.Conversation
Decoder for Conversation
.
encodeGroup : Mastodon.Entity.Group -> Json.Encode.Value
Encoder for Group
.
groupDecoder : Json.Decode.Decoder Mastodon.Entity.Group
Decoder for Group
.
encodeGroupRelationship : Mastodon.Entity.GroupRelationship -> Json.Encode.Value
Encoder for GroupRelationship
.
groupRelationshipDecoder : Json.Decode.Decoder Mastodon.Entity.GroupRelationship
Decoder for GroupRelationship
.
encodeTag : Mastodon.Entity.Tag -> Json.Encode.Value
Encode a Tag
.
tagDecoder : Json.Decode.Decoder Mastodon.Entity.Tag
Decode a Tag
.
translationDecoder : Json.Decode.Decoder Mastodon.Entity.Translation
Decoder for Translation
encodeTranslation : Mastodon.Entity.Translation -> Json.Encode.Value
Encoder for Translation
encodeAuthorization : Mastodon.Entity.Authorization -> Json.Encode.Value
Encoder for Authorization
.
authorizationDecoder : Json.Decode.Decoder Mastodon.Entity.Authorization
Decoder for Authorization
.
encodeMaybe : (x -> Json.Encode.Value) -> Maybe x -> Json.Encode.Value
Encode Maybe x
to Json.Encode.null
if it's Nothing,
or with the encoder otherwise.
encodePropertyAsList : String -> property -> (property -> Json.Encode.Value) -> property -> List ( String, Json.Encode.Value )
Useful for omitting encoded properties with a default value.
encodePropertyAsList name property encode default
Returns []
, if property == default
.
Otherwise, returns:
[ ( name, encoder property ) ]
privacyToString : Mastodon.Entity.Privacy -> String
Convert Privacy
to a String
.
notificationTypeToString : Mastodon.Entity.NotificationType -> String
Convert a NoticiationType
to a string
filterContextToString : Mastodon.Entity.FilterContext -> String
Turn a FilterContext
into a String
.