Giter Site home page Giter Site logo

alexforrester / android-moshi Goto Github PK

View Code? Open in Web Editor NEW
13.0 1.0 4.0 210 KB

Sample projects using Moshi Json parsing with codegen and reflection implemented with architecture components using data from The Movie Database

License: Apache License 2.0

Kotlin 100.00%
moshi mvvm-architecture mvvm-android koin viewmodel android architecture-components jetpack-navigation mockk espresso junit5

android-moshi's Introduction

android-moshi

Kotlin License

Sample projects using Android Architecture Components to illustrate Moshi parsing of JSON into Kotlin objects with codegen and reflection

Posting

Getting started using Moshi for JSON parsing with Kotlin: https://proandroiddev.com/getting-started-using-moshi-for-json-parsing-with-kotlin-5a460bf3935a

There are a number of libraries for parsing json into kotlin/java objects including Gson, Jackson and Moshi

Moshi is developed by Square and is targeted at the Android platform. It uses Kotlin language features to make parsing JSON data simpler and and more robust when handling null and absent responses. This repo illustrates some of Moshi's features and different implementations of how the library can be added in android projects using the reflection and codegen artifacts

App Description and Implementation

Both samples use androidx and ViewModel, LiveData and Navigation architecture components to display a list of Popular movies from The Movie Database which has been added as a file in the Assets folder. Selecting a movie will display a movie detail page including title, overview, image, the popularity of the movie in terms of the votes received and the genres it belongs to. The genres demonstrate bespoke parsing with Moshi to map Genre ids to Genres from the ingested JSON.

Unit tests use JUnit 5 and Mockk
Integration Tests use Espresso

Moshi Codegen and Reflection

The two samples differ only in how Moshi has been included and implemented with either the moshi-kotlin-codegen artifact for codegen and the moshi-kotlin artifact for reflection. More detail about the two options are in the official documentation.

License

Copyright 2019 Alex Forrester

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

android-moshi's People

Contributors

alexforrester avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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.