GithubHelp home page GithubHelp logo

mathieul / elm-jsonapi Goto Github PK

View Code? Open in Web Editor NEW

This project forked from noahzgordon/elm-jsonapi

0.0 2.0 0.0 58 KB

decoders and helper functions for handling JSON API compliant server payloads

Elm 99.54% Shell 0.46%

elm-jsonapi's Introduction

elm-jsonapi

elm-jsonapi decodes any JSON API compliant payload and provides helper functions for working with the results.

This library only provides base functionality for decoding payloads and working with the results. A more sophisticated wrapper which includes server negotiation is coming soon!

import Http
import JsonApi exposing (primaryResource)
import JsonApi.Decode exposing (document)
import Task exposing (..)


getUserResource : String -> Task Http.Error (JsonApi.Document)
getUserResource query =
    Http.get document ("http://www.jsonapi-compliant-server.com/users/" ++ query)

extractUsername : JsonApi.Document -> Maybe String
extractUsername doc =
  primaryResource doc
    |> Result.toMaybe
    |> Maybe.map JsonApi.attributes
    `Maybe.andThen` (Dict.get "username")

Known Issues

  • Links objects are unsupported. Links will only be captured if delivered as string values.
  • There is no dedicated type for Resource Identifiers. If your document's primary data is composed of Resource Identifiers, they will be represented as Resources without attributes or relationships.

contributing

elm-jsonapi is currently under development. I use waffle.io and Github Issues to track new features and bugs. if there's a feature you'd like to see, please submit an issue!

if you'd like to contribute yourself, please reach out to me or submit a pull request for the relevant issue.

Stories in Ready

elm-jsonapi's People

Contributors

noahzgordon avatar

Watchers

Mathieu Lajugie avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.