├── .gitignore ├── .idea ├── .gitignore ├── .name ├── compiler.xml ├── deploymentTargetDropDown.xml ├── gradle.xml ├── misc.xml └── vcs.xml ├── Help.md ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── hisham │ │ ├── jsondemo │ │ └── ExampleInstrumentedTest.kt │ │ └── jsonparsingdemo │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── hisham │ │ │ ├── jsondemo │ │ │ ├── MainActivity.kt │ │ │ ├── api │ │ │ │ └── MoviesApi.kt │ │ │ ├── model │ │ │ │ └── Movies.kt │ │ │ ├── retrofit │ │ │ │ ├── RetrofitApi.kt │ │ │ │ └── RetrofitInstance.kt │ │ │ ├── source │ │ │ │ ├── DataRepository.kt │ │ │ │ └── ManualParsingImpl.kt │ │ │ └── vm │ │ │ │ └── MainViewModel.kt │ │ │ └── jsonparsingdemo │ │ │ ├── MainActivity.kt │ │ │ ├── model │ │ │ └── Movie.kt │ │ │ ├── source │ │ │ ├── DataRepository.kt │ │ │ ├── ManualParsing.kt │ │ │ ├── MoviesApi.kt │ │ │ ├── RetroFitApi.kt │ │ │ └── RetrofitBuilder.kt │ │ │ └── vm │ │ │ └── MainActivityViewModel.kt │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── values-night │ │ └── themes.xml │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── themes.xml │ └── test │ └── java │ └── com │ └── hisham │ ├── jsondemo │ └── ExampleUnitTest.kt │ └── jsonparsingdemo │ └── ExampleUnitTest.kt ├── build.gradle ├── fbhosting ├── .firebaserc ├── .gitignore ├── firebase.json └── public │ ├── Android - JSON Parsing demo deck.pdf │ ├── images │ ├── avengers.jpg │ ├── dark_knight.jpg │ ├── f_four.jpg │ ├── gladiator.jpg │ ├── interstellar.jpg │ ├── life_is_beautiful.jpg │ ├── lion.jpg │ ├── lotr.jpg │ ├── saving_private_ryan.jpg │ └── walle.jpg │ ├── index.html │ ├── json │ ├── movie.json │ ├── moviesData.json │ ├── moviesDemoItem.json │ └── moviesDemoList.json │ └── jsonData │ ├── images │ ├── avengers.jpg │ ├── dark_knight.jpg │ ├── f_four.jpg │ ├── gladiator.jpg │ ├── interstellar.jpg │ ├── life_is_beautiful.jpg │ ├── lion.jpg │ ├── lotr.jpg │ ├── saving_private_ryan.jpg │ └── walle.jpg │ ├── moviesData.txt │ ├── moviesDemoItem.txt │ └── moviesDemoList.txt ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | local.properties 16 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | JsonDemo -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/deploymentTargetDropDown.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 17 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Help.md: -------------------------------------------------------------------------------- 1 | Steps for hosting files on Firebase: 2 | 3 | 1. Download and install Node.JS from here: https://nodejs.org/en/ 4 | 2. Open Node.js command prompt and install Firebase tools using this command: npm install -g firebase-tools 5 | 3. Create a directory and place server all server files in the directory 6 | 4. Via Node.js command prompt, navigate (cd path) to that directory in which you placed server files 7 | 5. Enter the following command in node.js command prompt and complete login: > firebase login 8 | 6. After logging in, enter command > firebase init 9 | 7. Follow the steps shown on the screen, after that check your server directory 10 | 8. Move your server directory inside the public folder just created. 11 | 9. Now deploy the files, using : > firebase deploy 12 | 10. Done. Check your files, they are public now. -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Hisham 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # JsonParsingDemo 2 | A simple demo for json parsing. 3 | 4 | You can watch the following tutorial to completely understand the json parsing:https://www.youtube.com/channel/UC-1b6coI0pJxDKdDT-v-Dww 5 | 6 | ![Screenshot_1615107479](https://user-images.githubusercontent.com/3941245/110234596-57613900-7f51-11eb-96b2-f6d86f8e1125.png) 7 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.application' 3 | id 'kotlin-android' 4 | } 5 | 6 | android { 7 | compileSdkVersion 30 8 | buildToolsVersion "30.0.3" 9 | 10 | defaultConfig { 11 | applicationId "com.hisham.jsondemo" 12 | minSdkVersion 21 13 | targetSdkVersion 30 14 | versionCode 1 15 | versionName "1.0" 16 | 17 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 18 | } 19 | 20 | buildTypes { 21 | release { 22 | minifyEnabled false 23 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 24 | } 25 | } 26 | compileOptions { 27 | sourceCompatibility JavaVersion.VERSION_1_8 28 | targetCompatibility JavaVersion.VERSION_1_8 29 | } 30 | kotlinOptions { 31 | jvmTarget = '1.8' 32 | } 33 | 34 | buildFeatures { 35 | viewBinding true 36 | } 37 | } 38 | 39 | dependencies { 40 | 41 | implementation 'androidx.core:core-ktx:1.3.2' 42 | implementation 'androidx.appcompat:appcompat:1.2.0' 43 | implementation 'com.google.android.material:material:1.3.0' 44 | implementation 'androidx.constraintlayout:constraintlayout:2.0.4' 45 | testImplementation 'junit:junit:4.+' 46 | androidTestImplementation 'androidx.test.ext:junit:1.1.2' 47 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' 48 | 49 | def lifecycle_version = "2.3.0" 50 | def arch_version = "2.1.0" 51 | 52 | // ViewModel 53 | implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version" 54 | // LiveData 55 | implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version" 56 | implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9' 57 | implementation 'com.google.code.gson:gson:2.8.6' 58 | 59 | implementation 'com.squareup.retrofit2:retrofit:2.9.0' 60 | implementation 'com.squareup.retrofit2:converter-gson:2.9.0' 61 | implementation 'com.github.bumptech.glide:glide:4.12.0' 62 | 63 | 64 | 65 | 66 | 67 | } -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /app/src/androidTest/java/com/hisham/jsondemo/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.hisham.jsondemo 2 | 3 | import androidx.test.platform.app.InstrumentationRegistry 4 | import androidx.test.ext.junit.runners.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 22 | assertEquals("com.hisham.jsondemo", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /app/src/androidTest/java/com/hisham/jsonparsingdemo/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.hisham.jsonparsingdemo 2 | 3 | import androidx.test.platform.app.InstrumentationRegistry 4 | import androidx.test.ext.junit.runners.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 22 | assertEquals("com.hisham.jsonparsingdemo", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 14 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/java/com/hisham/jsondemo/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.hisham.jsondemo 2 | 3 | import androidx.appcompat.app.AppCompatActivity 4 | import android.os.Bundle 5 | import androidx.lifecycle.ViewModelProvider 6 | import com.bumptech.glide.Glide 7 | import com.hisham.jsondemo.databinding.ActivityMainBinding 8 | import com.hisham.jsondemo.vm.MainViewModel 9 | 10 | class MainActivity : AppCompatActivity() { 11 | 12 | // View Binding 13 | private lateinit var binding: ActivityMainBinding 14 | 15 | // View Model 16 | private lateinit var viewModel: MainViewModel 17 | 18 | override fun onCreate(savedInstanceState: Bundle?) { 19 | super.onCreate(savedInstanceState) 20 | binding = ActivityMainBinding.inflate(layoutInflater) 21 | setContentView(binding.root) 22 | 23 | viewModel = ViewModelProvider(this)[MainViewModel::class.java] 24 | 25 | viewModel.movieLiveData.observe(this) { 26 | binding.tvHello.text = it.toString() 27 | Glide.with(this).load(it.image).into(binding.imageView) 28 | } 29 | viewModel.fetchMovie() 30 | 31 | 32 | } 33 | } -------------------------------------------------------------------------------- /app/src/main/java/com/hisham/jsondemo/api/MoviesApi.kt: -------------------------------------------------------------------------------- 1 | package com.hisham.jsondemo.api 2 | 3 | import com.hisham.jsondemo.model.Movies 4 | 5 | interface MoviesApi { 6 | 7 | suspend fun getMovies() : Movies 8 | 9 | } -------------------------------------------------------------------------------- /app/src/main/java/com/hisham/jsondemo/model/Movies.kt: -------------------------------------------------------------------------------- 1 | package com.hisham.jsondemo.model 2 | 3 | data class Movies( 4 | val movies: List 5 | ) 6 | 7 | data class Movie( 8 | val cast: List, 9 | val director: String, 10 | val duration: String, 11 | val image: String, 12 | val movie: String, 13 | val rating: Double, 14 | val story: String, 15 | val tagline: String, 16 | val year: Int 17 | ) 18 | 19 | data class Cast( 20 | val name: String 21 | ) 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/hisham/jsondemo/retrofit/RetrofitApi.kt: -------------------------------------------------------------------------------- 1 | package com.hisham.jsondemo.retrofit 2 | 3 | import com.hisham.jsondemo.api.MoviesApi 4 | import com.hisham.jsondemo.model.Movies 5 | import retrofit2.http.GET 6 | 7 | interface RetrofitApi : MoviesApi { 8 | 9 | @GET("/json/moviesData.json") 10 | override suspend fun getMovies(): Movies 11 | 12 | } -------------------------------------------------------------------------------- /app/src/main/java/com/hisham/jsondemo/retrofit/RetrofitInstance.kt: -------------------------------------------------------------------------------- 1 | package com.hisham.jsondemo.retrofit 2 | 3 | import retrofit2.Retrofit 4 | import retrofit2.converter.gson.GsonConverterFactory 5 | 6 | object RetrofitInstance { 7 | 8 | private val builder = Retrofit.Builder() 9 | .baseUrl("https://jsonparsingdemo-cec5b.firebaseapp.com") 10 | .addConverterFactory(GsonConverterFactory.create()) 11 | .build() 12 | 13 | val service = builder.create(RetrofitApi::class.java) 14 | 15 | } -------------------------------------------------------------------------------- /app/src/main/java/com/hisham/jsondemo/source/DataRepository.kt: -------------------------------------------------------------------------------- 1 | package com.hisham.jsondemo.source 2 | 3 | import com.hisham.jsondemo.api.MoviesApi 4 | import com.hisham.jsondemo.model.Movies 5 | 6 | class DataRepository(private val moviesApi: MoviesApi) { 7 | 8 | suspend fun getMovies() : Movies{ 9 | return moviesApi.getMovies() 10 | } 11 | 12 | } -------------------------------------------------------------------------------- /app/src/main/java/com/hisham/jsondemo/source/ManualParsingImpl.kt: -------------------------------------------------------------------------------- 1 | package com.hisham.jsondemo.source 2 | 3 | import com.google.gson.Gson 4 | import com.hisham.jsondemo.api.MoviesApi 5 | import com.hisham.jsondemo.model.Movies 6 | import java.io.BufferedInputStream 7 | import java.net.URL 8 | 9 | class ManualParsingImpl : MoviesApi { 10 | override suspend fun getMovies(): Movies { 11 | 12 | val url = URL("https://jsonparsingdemo-cec5b.firebaseapp.com/json/moviesDemoItem.json") 13 | val connection = url.openConnection() 14 | connection.connect() 15 | 16 | val bufferedInputStream = BufferedInputStream(connection.getInputStream()) 17 | val bufferedReader = bufferedInputStream.bufferedReader() 18 | 19 | val stringBuffer = StringBuffer() 20 | 21 | for (line in bufferedReader.readLines()) { 22 | stringBuffer.append(line) 23 | } 24 | 25 | bufferedReader.close() 26 | 27 | val fullJson = stringBuffer.toString() 28 | 29 | return Gson().fromJson(fullJson, Movies::class.java) 30 | 31 | // // json parsing 32 | // val jsonObjectMovies = JSONObject(fullJson) 33 | // val jsonArray = jsonObjectMovies.getJSONArray("movies") 34 | // val jsonObjectMovie = jsonArray.getJSONObject(0) 35 | // 36 | // val movieName = jsonObjectMovie.getString("movie") 37 | // val year = jsonObjectMovie.getInt("year") 38 | // val image = jsonObjectMovie.getString("image") 39 | // return Movies(listOf(Movie(movieName, year, image))) 40 | 41 | } 42 | } -------------------------------------------------------------------------------- /app/src/main/java/com/hisham/jsondemo/vm/MainViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.hisham.jsondemo.vm 2 | 3 | import androidx.lifecycle.MutableLiveData 4 | import androidx.lifecycle.ViewModel 5 | import androidx.lifecycle.viewModelScope 6 | import com.hisham.jsondemo.model.Movie 7 | import com.hisham.jsondemo.retrofit.RetrofitApi 8 | import com.hisham.jsondemo.retrofit.RetrofitInstance 9 | import com.hisham.jsondemo.source.DataRepository 10 | import kotlinx.coroutines.Dispatchers 11 | import kotlinx.coroutines.launch 12 | import kotlinx.coroutines.withContext 13 | 14 | class MainViewModel : ViewModel() { 15 | // private val dataRepository = DataRepository(ManualParsingImpl()) 16 | private val dataRepository = DataRepository(RetrofitInstance.service) 17 | 18 | val movieLiveData = MutableLiveData() 19 | 20 | fun fetchMovie() { 21 | viewModelScope.launch { 22 | val movie = withContext(Dispatchers.IO) { 23 | dataRepository.getMovies().movies[2] 24 | } 25 | movieLiveData.value = movie 26 | } 27 | } 28 | 29 | } -------------------------------------------------------------------------------- /app/src/main/java/com/hisham/jsonparsingdemo/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.hisham.jsonparsingdemo 2 | 3 | import android.os.Bundle 4 | import androidx.appcompat.app.AppCompatActivity 5 | import androidx.lifecycle.ViewModelProvider 6 | import com.bumptech.glide.Glide 7 | import com.hisham.jsonparsingdemo.databinding.ActivityMainBinding 8 | import com.hisham.jsonparsingdemo.vm.MainActivityViewModel 9 | 10 | class MainActivity : AppCompatActivity() { 11 | 12 | // View Model 13 | private lateinit var viewModel: MainActivityViewModel 14 | 15 | // View Binding 16 | private lateinit var binding: ActivityMainBinding 17 | 18 | override fun onCreate(savedInstanceState: Bundle?) { 19 | super.onCreate(savedInstanceState) 20 | binding = ActivityMainBinding.inflate(layoutInflater) 21 | setContentView(binding.root) 22 | viewModel = ViewModelProvider(this).get(MainActivityViewModel::class.java) 23 | 24 | viewModel.getMovies().observe(this) { 25 | binding.tvHello.text = it.movie.plus(" - ").plus(it.year) 26 | Glide.with(this).load(it.image).into(binding.imageView) 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /app/src/main/java/com/hisham/jsonparsingdemo/model/Movie.kt: -------------------------------------------------------------------------------- 1 | package com.hisham.jsonparsingdemo.model 2 | 3 | data class Movie(val movie: String, val year: Int, val image: String) 4 | 5 | data class MovieObject(val movies: List) -------------------------------------------------------------------------------- /app/src/main/java/com/hisham/jsonparsingdemo/source/DataRepository.kt: -------------------------------------------------------------------------------- 1 | package com.hisham.jsonparsingdemo.source 2 | 3 | import com.hisham.jsonparsingdemo.model.Movie 4 | import kotlinx.coroutines.GlobalScope 5 | import kotlinx.coroutines.async 6 | 7 | class DataRepository(private val moviesApi: MoviesApi) { 8 | 9 | suspend fun getMovies(): List { 10 | return moviesApi.getMovies().movies 11 | } 12 | 13 | suspend fun getMovie(): Movie { 14 | return moviesApi.getMovie() 15 | } 16 | } -------------------------------------------------------------------------------- /app/src/main/java/com/hisham/jsonparsingdemo/source/ManualParsing.kt: -------------------------------------------------------------------------------- 1 | package com.hisham.jsonparsingdemo.source 2 | 3 | import com.google.gson.Gson 4 | import com.hisham.jsonparsingdemo.model.Movie 5 | import com.hisham.jsonparsingdemo.model.MovieObject 6 | import java.io.BufferedInputStream 7 | import java.lang.Exception 8 | import java.net.URL 9 | import org.json.JSONObject 10 | 11 | class ManualParsing : MoviesApi { 12 | override suspend fun getMovies(): MovieObject { 13 | try { 14 | val url = URL("https://jsonparsingdemo-cec5b.firebaseapp.com/json/moviesDemoItem.json") 15 | val connection = url.openConnection() 16 | connection.connect() 17 | 18 | val inputStream = BufferedInputStream(url.openStream()) 19 | val bufferedReader = inputStream.bufferedReader() 20 | 21 | val stringBuffer = StringBuffer() 22 | 23 | for (line in bufferedReader.readLines()) { 24 | stringBuffer.append(line) 25 | } 26 | bufferedReader.close() 27 | 28 | // JSON parsing 29 | val json = stringBuffer.toString() 30 | 31 | return Gson().fromJson(json, MovieObject::class.java) 32 | 33 | // val topLevelObject = JSONObject(json) 34 | // val moviesArray = topLevelObject.getJSONArray("movies") 35 | // val movieObject = moviesArray.getJSONObject(0) 36 | // val movieName = movieObject.getString("movie") 37 | // val movieYear = movieObject.getInt("year") 38 | // return MovieObject(listOf(Movie(movieName.plus(" From manual parsing"), movieYear))) 39 | } catch (e: Exception) { 40 | return MovieObject(emptyList()) 41 | } 42 | } 43 | 44 | override suspend fun getMovie(): Movie { 45 | try { 46 | val url = URL("https://jsonparsingdemo-cec5b.firebaseapp.com/json/movie.json") 47 | val connection = url.openConnection() 48 | connection.connect() 49 | 50 | val inputStream = BufferedInputStream(url.openStream()) 51 | val bufferedReader = inputStream.bufferedReader() 52 | 53 | val stringBuffer = StringBuffer() 54 | 55 | for (line in bufferedReader.readLines()) { 56 | stringBuffer.append(line) 57 | } 58 | bufferedReader.close() 59 | 60 | // JSON parsing 61 | val json = stringBuffer.toString() 62 | 63 | return Gson().fromJson(json, Movie::class.java) 64 | 65 | // val topLevelObject = JSONObject(json) 66 | // val moviesArray = topLevelObject.getJSONArray("movies") 67 | // val movieObject = moviesArray.getJSONObject(0) 68 | // val movieName = movieObject.getString("movie") 69 | // val movieYear = movieObject.getInt("year") 70 | // return MovieObject(listOf(Movie(movieName.plus(" From manual parsing"), movieYear))) 71 | } catch (e: Exception) { 72 | return Movie("", -1, "") 73 | } 74 | } 75 | } -------------------------------------------------------------------------------- /app/src/main/java/com/hisham/jsonparsingdemo/source/MoviesApi.kt: -------------------------------------------------------------------------------- 1 | package com.hisham.jsonparsingdemo.source 2 | 3 | import com.hisham.jsonparsingdemo.model.Movie 4 | import com.hisham.jsonparsingdemo.model.MovieObject 5 | 6 | interface MoviesApi { 7 | suspend fun getMovies(): MovieObject 8 | 9 | suspend fun getMovie(): Movie 10 | } -------------------------------------------------------------------------------- /app/src/main/java/com/hisham/jsonparsingdemo/source/RetroFitApi.kt: -------------------------------------------------------------------------------- 1 | package com.hisham.jsonparsingdemo.source 2 | 3 | import com.hisham.jsonparsingdemo.model.Movie 4 | import com.hisham.jsonparsingdemo.model.MovieObject 5 | import retrofit2.http.GET 6 | 7 | interface RetroFitApi : MoviesApi { 8 | 9 | @GET("/json/moviesData.json") 10 | override suspend fun getMovies(): MovieObject 11 | 12 | 13 | @GET("/json/movie.json") 14 | override suspend fun getMovie(): Movie 15 | } -------------------------------------------------------------------------------- /app/src/main/java/com/hisham/jsonparsingdemo/source/RetrofitBuilder.kt: -------------------------------------------------------------------------------- 1 | package com.hisham.jsonparsingdemo.source 2 | 3 | import okhttp3.OkHttpClient 4 | import retrofit2.Retrofit 5 | import retrofit2.converter.gson.GsonConverterFactory 6 | 7 | object RetrofitBuilder { 8 | 9 | private val client = OkHttpClient.Builder().build() 10 | 11 | private val retrofit = Retrofit.Builder() 12 | .baseUrl("https://jsonparsingdemo-cec5b.web.app/") 13 | .addConverterFactory(GsonConverterFactory.create()) 14 | .client(client) 15 | .build() 16 | 17 | fun getService(): RetroFitApi { 18 | return retrofit.create(RetroFitApi::class.java) 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /app/src/main/java/com/hisham/jsonparsingdemo/vm/MainActivityViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.hisham.jsonparsingdemo.vm 2 | 3 | import androidx.lifecycle.LiveData 4 | import androidx.lifecycle.MutableLiveData 5 | import androidx.lifecycle.ViewModel 6 | import androidx.lifecycle.viewModelScope 7 | import com.hisham.jsonparsingdemo.model.Movie 8 | import com.hisham.jsonparsingdemo.source.DataRepository 9 | import com.hisham.jsonparsingdemo.source.ManualParsing 10 | import kotlinx.coroutines.Dispatchers 11 | import kotlinx.coroutines.launch 12 | import kotlinx.coroutines.withContext 13 | 14 | class MainActivityViewModel : ViewModel() { 15 | 16 | // LiveData 17 | private val movieList = MutableLiveData() 18 | 19 | private val dataRepository = DataRepository(ManualParsing()) 20 | // private val dataRepository = DataRepository(RetrofitBuilder.getService()) 21 | 22 | fun getMovies(): LiveData { 23 | viewModelScope.launch { 24 | val movieData = withContext(Dispatchers.IO) { 25 | dataRepository.getMovie() 26 | } 27 | movieList.value = movieData 28 | } 29 | return movieList 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 19 | 20 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hishamMuneer/JsonParsingDemo/9b449df747a16426811cdf319d990ac7fe0c0bb0/app/src/main/res/mipmap-hdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hishamMuneer/JsonParsingDemo/9b449df747a16426811cdf319d990ac7fe0c0bb0/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hishamMuneer/JsonParsingDemo/9b449df747a16426811cdf319d990ac7fe0c0bb0/app/src/main/res/mipmap-mdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hishamMuneer/JsonParsingDemo/9b449df747a16426811cdf319d990ac7fe0c0bb0/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hishamMuneer/JsonParsingDemo/9b449df747a16426811cdf319d990ac7fe0c0bb0/app/src/main/res/mipmap-xhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hishamMuneer/JsonParsingDemo/9b449df747a16426811cdf319d990ac7fe0c0bb0/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hishamMuneer/JsonParsingDemo/9b449df747a16426811cdf319d990ac7fe0c0bb0/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hishamMuneer/JsonParsingDemo/9b449df747a16426811cdf319d990ac7fe0c0bb0/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hishamMuneer/JsonParsingDemo/9b449df747a16426811cdf319d990ac7fe0c0bb0/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hishamMuneer/JsonParsingDemo/9b449df747a16426811cdf319d990ac7fe0c0bb0/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/values-night/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF6200EE 5 | #FF3700B3 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | JsonDemo 3 | -------------------------------------------------------------------------------- /app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /app/src/test/java/com/hisham/jsondemo/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.hisham.jsondemo 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * See [testing documentation](http://d.android.com/tools/testing). 11 | */ 12 | class ExampleUnitTest { 13 | @Test 14 | fun addition_isCorrect() { 15 | assertEquals(4, 2 + 2) 16 | } 17 | } -------------------------------------------------------------------------------- /app/src/test/java/com/hisham/jsonparsingdemo/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.hisham.jsonparsingdemo 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * See [testing documentation](http://d.android.com/tools/testing). 11 | */ 12 | class ExampleUnitTest { 13 | @Test 14 | fun addition_isCorrect() { 15 | assertEquals(4, 2 + 2) 16 | } 17 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | buildscript { 3 | repositories { 4 | google() 5 | mavenCentral() 6 | } 7 | dependencies { 8 | classpath "com.android.tools.build:gradle:7.0.0-alpha08" 9 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.30" 10 | 11 | // NOTE: Do not place your application dependencies here; they belong 12 | // in the individual module build.gradle files 13 | } 14 | } 15 | 16 | task clean(type: Delete) { 17 | delete rootProject.buildDir 18 | } -------------------------------------------------------------------------------- /fbhosting/.firebaserc: -------------------------------------------------------------------------------- 1 | { 2 | "projects": { 3 | "default": "jsonparsingdemo-cec5b" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /fbhosting/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | firebase-debug.log* 8 | firebase-debug.*.log* 9 | 10 | # Firebase cache 11 | .firebase/ 12 | 13 | # Firebase config 14 | 15 | # Uncomment this if you'd like others to create their own Firebase project. 16 | # For a team working on the same Firebase project(s), it is recommended to leave 17 | # it commented so all members can deploy to the same project(s) in .firebaserc. 18 | # .firebaserc 19 | 20 | # Runtime data 21 | pids 22 | *.pid 23 | *.seed 24 | *.pid.lock 25 | 26 | # Directory for instrumented libs generated by jscoverage/JSCover 27 | lib-cov 28 | 29 | # Coverage directory used by tools like istanbul 30 | coverage 31 | 32 | # nyc test coverage 33 | .nyc_output 34 | 35 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 36 | .grunt 37 | 38 | # Bower dependency directory (https://bower.io/) 39 | bower_components 40 | 41 | # node-waf configuration 42 | .lock-wscript 43 | 44 | # Compiled binary addons (http://nodejs.org/api/addons.html) 45 | build/Release 46 | 47 | # Dependency directories 48 | node_modules/ 49 | 50 | # Optional npm cache directory 51 | .npm 52 | 53 | # Optional eslint cache 54 | .eslintcache 55 | 56 | # Optional REPL history 57 | .node_repl_history 58 | 59 | # Output of 'npm pack' 60 | *.tgz 61 | 62 | # Yarn Integrity file 63 | .yarn-integrity 64 | 65 | # dotenv environment variables file 66 | .env 67 | -------------------------------------------------------------------------------- /fbhosting/firebase.json: -------------------------------------------------------------------------------- 1 | { 2 | "hosting": { 3 | "public": "public", 4 | "ignore": [ 5 | "firebase.json", 6 | "**/.*", 7 | "**/node_modules/**" 8 | ], 9 | "rewrites": [ 10 | { 11 | "source": "**", 12 | "destination": "/index.html" 13 | } 14 | ] 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /fbhosting/public/Android - JSON Parsing demo deck.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hishamMuneer/JsonParsingDemo/9b449df747a16426811cdf319d990ac7fe0c0bb0/fbhosting/public/Android - JSON Parsing demo deck.pdf -------------------------------------------------------------------------------- /fbhosting/public/images/avengers.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hishamMuneer/JsonParsingDemo/9b449df747a16426811cdf319d990ac7fe0c0bb0/fbhosting/public/images/avengers.jpg -------------------------------------------------------------------------------- /fbhosting/public/images/dark_knight.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hishamMuneer/JsonParsingDemo/9b449df747a16426811cdf319d990ac7fe0c0bb0/fbhosting/public/images/dark_knight.jpg -------------------------------------------------------------------------------- /fbhosting/public/images/f_four.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hishamMuneer/JsonParsingDemo/9b449df747a16426811cdf319d990ac7fe0c0bb0/fbhosting/public/images/f_four.jpg -------------------------------------------------------------------------------- /fbhosting/public/images/gladiator.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hishamMuneer/JsonParsingDemo/9b449df747a16426811cdf319d990ac7fe0c0bb0/fbhosting/public/images/gladiator.jpg -------------------------------------------------------------------------------- /fbhosting/public/images/interstellar.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hishamMuneer/JsonParsingDemo/9b449df747a16426811cdf319d990ac7fe0c0bb0/fbhosting/public/images/interstellar.jpg -------------------------------------------------------------------------------- /fbhosting/public/images/life_is_beautiful.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hishamMuneer/JsonParsingDemo/9b449df747a16426811cdf319d990ac7fe0c0bb0/fbhosting/public/images/life_is_beautiful.jpg -------------------------------------------------------------------------------- /fbhosting/public/images/lion.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hishamMuneer/JsonParsingDemo/9b449df747a16426811cdf319d990ac7fe0c0bb0/fbhosting/public/images/lion.jpg -------------------------------------------------------------------------------- /fbhosting/public/images/lotr.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hishamMuneer/JsonParsingDemo/9b449df747a16426811cdf319d990ac7fe0c0bb0/fbhosting/public/images/lotr.jpg -------------------------------------------------------------------------------- /fbhosting/public/images/saving_private_ryan.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hishamMuneer/JsonParsingDemo/9b449df747a16426811cdf319d990ac7fe0c0bb0/fbhosting/public/images/saving_private_ryan.jpg -------------------------------------------------------------------------------- /fbhosting/public/images/walle.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hishamMuneer/JsonParsingDemo/9b449df747a16426811cdf319d990ac7fe0c0bb0/fbhosting/public/images/walle.jpg -------------------------------------------------------------------------------- /fbhosting/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Welcome to Firebase Hosting 6 | 60 | 61 | 62 |
63 |

Welcome to Json Parsing Demo

64 |

There are multiple types of json files hosted on this server that you can check using the following links:

65 | 75 | 76 |

You can download the deck (PPT) from here

77 | 82 |
83 | 84 | 85 | -------------------------------------------------------------------------------- /fbhosting/public/json/movie.json: -------------------------------------------------------------------------------- 1 | { 2 | "movie": "Avengers", 3 | "year": 2012, 4 | "rating": 7.8, 5 | "duration": "141 min", 6 | "director": "Joss Whedon", 7 | "tagline": "A new age begins", 8 | "cast": [ 9 | { 10 | "name": "Robert Downey Jr." 11 | }, 12 | { 13 | "name": "Chris Evans" 14 | }, 15 | { 16 | "name": "Mark Ruffalo" 17 | } 18 | ], 19 | "image": "https://jsonparsingdemo-cec5b.firebaseapp.com/jsonData/images/avengers.jpg", 20 | "story": "When Tony Stark and Bruce Banner try to jump-start a dormant peacekeeping program called Ultron, things go horribly wrong and it's up to Earth's Mightiest Heroes to stop the villainous Ultron from enacting his terrible plans." 21 | } -------------------------------------------------------------------------------- /fbhosting/public/json/moviesData.json: -------------------------------------------------------------------------------- 1 | { 2 | "movies": [ 3 | { 4 | "movie": "Avengers", 5 | "year": 2012, 6 | "rating": 7.8, 7 | "duration": "141 min", 8 | "director": "Joss Whedon", 9 | "tagline": "A new age begins", 10 | "cast": [ 11 | { 12 | "name": "Robert Downey Jr." 13 | }, 14 | { 15 | "name": "Chris Evans" 16 | }, 17 | { 18 | "name": "Mark Ruffalo" 19 | } 20 | ], 21 | "image": "https://jsonparsingdemo-cec5b.firebaseapp.com/jsonData/images/avengers.jpg", 22 | "story": "When Tony Stark and Bruce Banner try to jump-start a dormant peacekeeping program called Ultron, things go horribly wrong and it's up to Earth's Mightiest Heroes to stop the villainous Ultron from enacting his terrible plans." 23 | }, 24 | { 25 | "movie": "Interstellar", 26 | "year": 2014, 27 | "rating": 8.7, 28 | "duration": "169 min", 29 | "director": "Christopher Nolan", 30 | "tagline": "Mankind was born on Earth. It was never meant to die here.", 31 | "cast": [ 32 | { 33 | "name": "Matthew McConaughey" 34 | }, 35 | { 36 | "name": "Anne Hathaway" 37 | }, 38 | { 39 | "name": "Jessica Chastain" 40 | }, 41 | { 42 | "name": "Wes Bentley" 43 | } 44 | ], 45 | "image": "https://jsonparsingdemo-cec5b.firebaseapp.com/jsonData/images/interstellar.jpg", 46 | "story": "A team of explorers travel through a wormhole in space in an attempt to ensure humanity's survival." 47 | }, 48 | { 49 | "movie": "Fantastic Four", 50 | "year": 2015, 51 | "rating": 4.0, 52 | "duration": "100 min", 53 | "director": "Josh Trank", 54 | "tagline": "Change is coming.", 55 | "cast": [ 56 | { 57 | "name": "Miles Teller" 58 | }, 59 | { 60 | "name": "Kate Mara" 61 | }, 62 | { 63 | "name": "Michael B. Jordan" 64 | } 65 | ], 66 | "image": "https://jsonparsingdemo-cec5b.firebaseapp.com/jsonData/images/f_four.jpg", 67 | "story": "Four young outsiders teleport to an alternate and dangerous universe which alters their physical form in shocking ways. The four must learn to harness their new abilities and work together to save Earth from a former friend turned enemy." 68 | }, 69 | { 70 | "movie": "The Dark Knight", 71 | "year": 2008, 72 | "rating": 9.0, 73 | "duration": "152 min", 74 | "director": "Christopher Nolan", 75 | "tagline": "Why So Serious?", 76 | "cast": [ 77 | { 78 | "name": "Christian Bale" 79 | }, 80 | { 81 | "name": "Heath Ledger" 82 | }, 83 | { 84 | "name": "Aaron Eckhart" 85 | } 86 | ], 87 | "image": "https://jsonparsingdemo-cec5b.firebaseapp.com/jsonData/images/dark_knight.jpg", 88 | "story": "When the menace known as the Joker wreaks havoc and chaos on the people of Gotham, the caped crusader must come to terms with one of the greatest psychological tests of his ability to fight injustice." 89 | }, 90 | { 91 | "movie": "The Lord of the Rings: The Return of the King", 92 | "year": 2003, 93 | "rating": 8.9, 94 | "duration": "201 min", 95 | "director": "Peter Jackson", 96 | "tagline": "This Christmas the journey ends.", 97 | "cast": [ 98 | { 99 | "name": "Viggo Mortensen" 100 | }, 101 | { 102 | "name": "Ian McKellen" 103 | }, 104 | { 105 | "name": "Elijah Wood" 106 | } 107 | ], 108 | "image": "https://jsonparsingdemo-cec5b.firebaseapp.com/jsonData/images/lotr.jpg", 109 | "story": "Gandalf and Aragorn lead the World of Men against Sauron's army to draw his gaze from Frodo and Sam as they approach Mount Doom with the One Ring." 110 | }, 111 | { 112 | "movie": "Life Is Beautiful", 113 | "year": 1997, 114 | "rating": 8.6, 115 | "duration": "116 min", 116 | "director": "Roberto Benigni", 117 | "tagline": "An unforgettable fable that proves love, family and imagination conquer all.", 118 | "cast": [ 119 | { 120 | "name": "Roberto Benigni" 121 | }, 122 | { 123 | "name": "Nicoletta Braschi" 124 | }, 125 | { 126 | "name": "Giorgio Cantarini" 127 | } 128 | ], 129 | "image": "https://jsonparsingdemo-cec5b.firebaseapp.com/jsonData/images/life_is_beautiful.jpg", 130 | "story": "When an open-minded Jewish librarian and his son become victims of the Holocaust, he uses a perfect mixture of will, humor and imagination to protect his son from the dangers around their camp." 131 | }, 132 | { 133 | "movie": "Gladiator", 134 | "year": 2000, 135 | "rating": 8.5, 136 | "duration": "155 min", 137 | "director": "Ridley Scott", 138 | "tagline": "Father of a murdered son, husband to a murdered wife and I shall have my vengeance in this life or the next", 139 | "cast": [ 140 | { 141 | "name": "Russell Crowe" 142 | }, 143 | { 144 | "name": "Joaquin Phoenix" 145 | }, 146 | { 147 | "name": "Connie Nielsen" 148 | }, 149 | { 150 | "name": "Oliver Reed" 151 | }, 152 | { 153 | "name": "Tommy Flanagan" 154 | } 155 | ], 156 | "image": "https://jsonparsingdemo-cec5b.firebaseapp.com/jsonData/images/gladiator.jpg", 157 | "story": "When a Roman general is betrayed and his family murdered by an emperor's corrupt son, he comes to Rome as a gladiator to seek revenge." 158 | }, 159 | { 160 | "movie": "The Lion King", 161 | "year": 1994, 162 | "rating": 8.5, 163 | "duration": "89 min", 164 | "director": "Roger Allers", 165 | "tagline": "The King Has Returned.", 166 | "cast": [ 167 | { 168 | "name": "James Earl Jones" 169 | }, 170 | { 171 | "name": "Jeremy Irons" 172 | }, 173 | { 174 | "name": "Matthew Broderick" 175 | } 176 | ], 177 | "image": "https://jsonparsingdemo-cec5b.firebaseapp.com/jsonData/images/lion.jpg", 178 | "story": "Lion cub and future king Simba searches for his identity. His eagerness to please others and penchant for testing his boundaries sometimes gets him into trouble." 179 | }, 180 | { 181 | "movie": "WALL-E", 182 | "year": 2008, 183 | "rating": 8.4, 184 | "duration": "98 min", 185 | "director": "Andrew Stanton", 186 | "tagline": "He's got a lot of time on his hands.", 187 | "cast": [ 188 | { 189 | "name": "Ben Burtt" 190 | }, 191 | { 192 | "name": "Elissa Knight" 193 | }, 194 | { 195 | "name": "Jeff Garlin" 196 | } 197 | ], 198 | "image": "https://jsonparsingdemo-cec5b.firebaseapp.com/jsonData/images/walle.jpg", 199 | "story": "In the distant future, a small waste collecting robot inadvertently embarks on a space journey that will ultimately decide the fate of mankind." 200 | }, 201 | { 202 | "movie": "Saving Private Ryan", 203 | "year": 1998, 204 | "rating": 8.6, 205 | "duration": "169 min", 206 | "director": "Steven Spielberg", 207 | "tagline": "There was only one man left in the family, and the mission was to save him", 208 | "cast": [ 209 | { 210 | "name": "Tom Hanks" 211 | }, 212 | { 213 | "name": "Matt Damon" 214 | } 215 | ], 216 | "image": "https://jsonparsingdemo-cec5b.firebaseapp.com/jsonData/images/saving_private_ryan.jpg", 217 | "story": "Following the Normandy Landings, a group of U.S. soldiers go behind enemy lines to retrieve a paratrooper whose brothers have been killed in action." 218 | } 219 | ] 220 | } -------------------------------------------------------------------------------- /fbhosting/public/json/moviesDemoItem.json: -------------------------------------------------------------------------------- 1 | { 2 | "movies": [ 3 | { 4 | "movie": "Avengers", 5 | "year": 2012, 6 | "image": "https://jsonparsingdemo-cec5b.firebaseapp.com/jsonData/images/avengers.jpg" 7 | } 8 | ] 9 | } -------------------------------------------------------------------------------- /fbhosting/public/json/moviesDemoList.json: -------------------------------------------------------------------------------- 1 | { 2 | "movies": [ 3 | { 4 | "movie": "Avengers", 5 | "year": 2012 6 | }, 7 | { 8 | "movie": "Interstellar", 9 | "year": 2014 10 | }, 11 | { 12 | "movie": "Fantastic Four", 13 | "year": 2015 14 | }, 15 | { 16 | "movie": "The Dark Knight", 17 | "year": 2008 18 | }, 19 | { 20 | "movie": "The Lord of the Rings: The Return of the King", 21 | "year": 2003 22 | }, 23 | { 24 | "movie": "Life is Beautiful", 25 | "year": 1997 26 | }, 27 | { 28 | "movie": "Gladiator", 29 | "year": 2000 30 | }, 31 | { 32 | "movie": "The Lion King", 33 | "year": 1994 34 | }, 35 | { 36 | "movie": "WALL-E", 37 | "year": 2008 38 | }, 39 | { 40 | "movie": "Saving Private Ryan", 41 | "year": 1998 42 | } 43 | ] 44 | } -------------------------------------------------------------------------------- /fbhosting/public/jsonData/images/avengers.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hishamMuneer/JsonParsingDemo/9b449df747a16426811cdf319d990ac7fe0c0bb0/fbhosting/public/jsonData/images/avengers.jpg -------------------------------------------------------------------------------- /fbhosting/public/jsonData/images/dark_knight.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hishamMuneer/JsonParsingDemo/9b449df747a16426811cdf319d990ac7fe0c0bb0/fbhosting/public/jsonData/images/dark_knight.jpg -------------------------------------------------------------------------------- /fbhosting/public/jsonData/images/f_four.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hishamMuneer/JsonParsingDemo/9b449df747a16426811cdf319d990ac7fe0c0bb0/fbhosting/public/jsonData/images/f_four.jpg -------------------------------------------------------------------------------- /fbhosting/public/jsonData/images/gladiator.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hishamMuneer/JsonParsingDemo/9b449df747a16426811cdf319d990ac7fe0c0bb0/fbhosting/public/jsonData/images/gladiator.jpg -------------------------------------------------------------------------------- /fbhosting/public/jsonData/images/interstellar.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hishamMuneer/JsonParsingDemo/9b449df747a16426811cdf319d990ac7fe0c0bb0/fbhosting/public/jsonData/images/interstellar.jpg -------------------------------------------------------------------------------- /fbhosting/public/jsonData/images/life_is_beautiful.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hishamMuneer/JsonParsingDemo/9b449df747a16426811cdf319d990ac7fe0c0bb0/fbhosting/public/jsonData/images/life_is_beautiful.jpg -------------------------------------------------------------------------------- /fbhosting/public/jsonData/images/lion.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hishamMuneer/JsonParsingDemo/9b449df747a16426811cdf319d990ac7fe0c0bb0/fbhosting/public/jsonData/images/lion.jpg -------------------------------------------------------------------------------- /fbhosting/public/jsonData/images/lotr.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hishamMuneer/JsonParsingDemo/9b449df747a16426811cdf319d990ac7fe0c0bb0/fbhosting/public/jsonData/images/lotr.jpg -------------------------------------------------------------------------------- /fbhosting/public/jsonData/images/saving_private_ryan.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hishamMuneer/JsonParsingDemo/9b449df747a16426811cdf319d990ac7fe0c0bb0/fbhosting/public/jsonData/images/saving_private_ryan.jpg -------------------------------------------------------------------------------- /fbhosting/public/jsonData/images/walle.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hishamMuneer/JsonParsingDemo/9b449df747a16426811cdf319d990ac7fe0c0bb0/fbhosting/public/jsonData/images/walle.jpg -------------------------------------------------------------------------------- /fbhosting/public/jsonData/moviesData.txt: -------------------------------------------------------------------------------- 1 | { 2 | "movies": [ 3 | { 4 | "movie": "Avengers", 5 | "year": 2012, 6 | "rating": 7.8, 7 | "duration": "141 min", 8 | "director": "Joss Whedon", 9 | "tagline": "A new age begins", 10 | "cast": [ 11 | { 12 | "name": "Robert Downey Jr." 13 | }, 14 | { 15 | "name": "Chris Evans" 16 | }, 17 | { 18 | "name": "Mark Ruffalo" 19 | } 20 | ], 21 | "image": "https://jsonparsingdemo-cec5b.firebaseapp.com/jsonData/images/avengers.jpg", 22 | "story": "When Tony Stark and Bruce Banner try to jump-start a dormant peacekeeping program called Ultron, things go horribly wrong and it's up to Earth's Mightiest Heroes to stop the villainous Ultron from enacting his terrible plans." 23 | }, 24 | { 25 | "movie": "Interstellar", 26 | "year": 2014, 27 | "rating": 8.7, 28 | "duration": "169 min", 29 | "director": "Christopher Nolan", 30 | "tagline": "Mankind was born on Earth. It was never meant to die here.", 31 | "cast": [ 32 | { 33 | "name": "Matthew McConaughey" 34 | }, 35 | { 36 | "name": "Anne Hathaway" 37 | }, 38 | { 39 | "name": "Jessica Chastain" 40 | }, 41 | { 42 | "name": "Wes Bentley" 43 | } 44 | ], 45 | "image": "https://jsonparsingdemo-cec5b.firebaseapp.com/jsonData/images/interstellar.jpg", 46 | "story": "A team of explorers travel through a wormhole in space in an attempt to ensure humanity's survival." 47 | }, 48 | { 49 | "movie": "Fantastic Four", 50 | "year": 2015, 51 | "rating": 4.0, 52 | "duration": "100 min", 53 | "director": "Josh Trank", 54 | "tagline": "Change is coming.", 55 | "cast": [ 56 | { 57 | "name": "Miles Teller" 58 | }, 59 | { 60 | "name": "Kate Mara" 61 | }, 62 | { 63 | "name": "Michael B. Jordan" 64 | } 65 | ], 66 | "image": "https://jsonparsingdemo-cec5b.firebaseapp.com/jsonData/images/f_four.jpg", 67 | "story": "Four young outsiders teleport to an alternate and dangerous universe which alters their physical form in shocking ways. The four must learn to harness their new abilities and work together to save Earth from a former friend turned enemy." 68 | }, 69 | { 70 | "movie": "The Dark Knight", 71 | "year": 2008, 72 | "rating": 9.0, 73 | "duration": "152 min", 74 | "director": "Christopher Nolan", 75 | "tagline": "Why So Serious?", 76 | "cast": [ 77 | { 78 | "name": "Christian Bale" 79 | }, 80 | { 81 | "name": "Heath Ledger" 82 | }, 83 | { 84 | "name": "Aaron Eckhart" 85 | } 86 | ], 87 | "image": "https://jsonparsingdemo-cec5b.firebaseapp.com/jsonData/images/dark_knight.jpg", 88 | "story": "When the menace known as the Joker wreaks havoc and chaos on the people of Gotham, the caped crusader must come to terms with one of the greatest psychological tests of his ability to fight injustice." 89 | }, 90 | { 91 | "movie": "The Lord of the Rings: The Return of the King", 92 | "year": 2003, 93 | "rating": 8.9, 94 | "duration": "201 min", 95 | "director": "Peter Jackson", 96 | "tagline": "This Christmas the journey ends.", 97 | "cast": [ 98 | { 99 | "name": "Viggo Mortensen" 100 | }, 101 | { 102 | "name": "Ian McKellen" 103 | }, 104 | { 105 | "name": "Elijah Wood" 106 | } 107 | ], 108 | "image": "https://jsonparsingdemo-cec5b.firebaseapp.com/jsonData/images/lotr.jpg", 109 | "story": "Gandalf and Aragorn lead the World of Men against Sauron's army to draw his gaze from Frodo and Sam as they approach Mount Doom with the One Ring." 110 | }, 111 | { 112 | "movie": "Life Is Beautiful", 113 | "year": 1997, 114 | "rating": 8.6, 115 | "duration": "116 min", 116 | "director": "Roberto Benigni", 117 | "tagline": "An unforgettable fable that proves love, family and imagination conquer all.", 118 | "cast": [ 119 | { 120 | "name": "Roberto Benigni" 121 | }, 122 | { 123 | "name": "Nicoletta Braschi" 124 | }, 125 | { 126 | "name": "Giorgio Cantarini" 127 | } 128 | ], 129 | "image": "https://jsonparsingdemo-cec5b.firebaseapp.com/jsonData/images/life_is_beautiful.jpg", 130 | "story": "When an open-minded Jewish librarian and his son become victims of the Holocaust, he uses a perfect mixture of will, humor and imagination to protect his son from the dangers around their camp." 131 | }, 132 | { 133 | "movie": "Gladiator", 134 | "year": 2000, 135 | "rating": 8.5, 136 | "duration": "155 min", 137 | "director": "Ridley Scott", 138 | "tagline": "Father of a murdered son, husband to a murdered wife and I shall have my vengeance in this life or the next", 139 | "cast": [ 140 | { 141 | "name": "Russell Crowe" 142 | }, 143 | { 144 | "name": "Joaquin Phoenix" 145 | }, 146 | { 147 | "name": "Connie Nielsen" 148 | }, 149 | { 150 | "name": "Oliver Reed" 151 | }, 152 | { 153 | "name": "Tommy Flanagan" 154 | } 155 | ], 156 | "image": "https://jsonparsingdemo-cec5b.firebaseapp.com/jsonData/images/gladiator.jpg", 157 | "story": "When a Roman general is betrayed and his family murdered by an emperor's corrupt son, he comes to Rome as a gladiator to seek revenge." 158 | }, 159 | { 160 | "movie": "The Lion King", 161 | "year": 1994, 162 | "rating": 8.5, 163 | "duration": "89 min", 164 | "director": "Roger Allers", 165 | "tagline": "The King Has Returned.", 166 | "cast": [ 167 | { 168 | "name": "James Earl Jones" 169 | }, 170 | { 171 | "name": "Jeremy Irons" 172 | }, 173 | { 174 | "name": "Matthew Broderick" 175 | } 176 | ], 177 | "image": "https://jsonparsingdemo-cec5b.firebaseapp.com/jsonData/images/lion.jpg", 178 | "story": "Lion cub and future king Simba searches for his identity. His eagerness to please others and penchant for testing his boundaries sometimes gets him into trouble." 179 | }, 180 | { 181 | "movie": "WALL-E", 182 | "year": 2008, 183 | "rating": 8.4, 184 | "duration": "98 min", 185 | "director": "Andrew Stanton", 186 | "tagline": "He's got a lot of time on his hands.", 187 | "cast": [ 188 | { 189 | "name": "Ben Burtt" 190 | }, 191 | { 192 | "name": "Elissa Knight" 193 | }, 194 | { 195 | "name": "Jeff Garlin" 196 | } 197 | ], 198 | "image": "https://jsonparsingdemo-cec5b.firebaseapp.com/jsonData/images/walle.jpg", 199 | "story": "In the distant future, a small waste collecting robot inadvertently embarks on a space journey that will ultimately decide the fate of mankind." 200 | }, 201 | { 202 | "movie": "Saving Private Ryan", 203 | "year": 1998, 204 | "rating": 8.6, 205 | "duration": "169 min", 206 | "director": "Steven Spielberg", 207 | "tagline": "There was only one man left in the family, and the mission was to save him", 208 | "cast": [ 209 | { 210 | "name": "Tom Hanks" 211 | }, 212 | { 213 | "name": "Matt Damon" 214 | } 215 | ], 216 | "image": "https://jsonparsingdemo-cec5b.firebaseapp.com/jsonData/images/saving_private_ryan.jpg", 217 | "story": "Following the Normandy Landings, a group of U.S. soldiers go behind enemy lines to retrieve a paratrooper whose brothers have been killed in action." 218 | } 219 | ] 220 | } -------------------------------------------------------------------------------- /fbhosting/public/jsonData/moviesDemoItem.txt: -------------------------------------------------------------------------------- 1 | { 2 | "movies": [ 3 | { 4 | "movie": "Avengers", 5 | "year": 2012 6 | } 7 | ] 8 | } -------------------------------------------------------------------------------- /fbhosting/public/jsonData/moviesDemoList.txt: -------------------------------------------------------------------------------- 1 | { 2 | "movies": [ 3 | { 4 | "movie": "Avengers", 5 | "year": 2012 6 | }, 7 | { 8 | "movie": "Interstellar", 9 | "year": 2014 10 | }, 11 | { 12 | "movie": "Fantastic Four", 13 | "year": 2015 14 | }, 15 | { 16 | "movie": "The Dark Knight", 17 | "year": 2008 18 | }, 19 | { 20 | "movie": "The Lord of the Rings: The Return of the King", 21 | "year": 2003 22 | }, 23 | { 24 | "movie": "Life is Beautiful", 25 | "year": 1997 26 | }, 27 | { 28 | "movie": "Gladiator", 29 | "year": 2000 30 | }, 31 | { 32 | "movie": "The Lion King", 33 | "year": 1994 34 | }, 35 | { 36 | "movie": "WALL-E", 37 | "year": 2008 38 | }, 39 | { 40 | "movie": "Saving Private Ryan", 41 | "year": 1998 42 | } 43 | ] 44 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app"s APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Automatically convert third-party libraries to use AndroidX 19 | android.enableJetifier=true 20 | # Kotlin code style for this project: "official" or "obsolete": 21 | kotlin.code.style=official -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hishamMuneer/JsonParsingDemo/9b449df747a16426811cdf319d990ac7fe0c0bb0/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sun Mar 07 13:34:02 IST 2021 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-bin.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 3 | repositories { 4 | google() 5 | mavenCentral() 6 | jcenter() // Warning: this repository is going to shut down soon 7 | } 8 | } 9 | rootProject.name = "JsonDemo" 10 | include ':app' 11 | --------------------------------------------------------------------------------