Skip to content

pvarry/android-json-viewer

Repository files navigation

android-json-view

Andorid JSON Viewer

With this library you can display long JSON in a android view, you can click on a key to hide and show the sub tree.

Usage

Gradle

  • Project level build.gradle
allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
    }
}
  • App level build.gradle
dependencies {
    implementation 'com.github.pvarry:android-json-viewer:v1.1'
}

Maven

<!-- <repositories> section of pom.xml -->
<repository>
    <id>jitpack.io</id>
   <url>https://jitpack.io</url>
</repository>


<!-- <dependencies> section of pom.xml -->
<dependency>
    <groupId>com.github.pvarry</groupId>
    <artifactId>android-json-viewer</artifactId>
    <version>v1.1</version>
</dependency>

Documentation 📖

<com.paulvarry.jsonviewer.JsonViewer
    android:id="@+id/jsonViewer"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

void setJson(Object json)

Set the JSON, must be org.json.JSONObject or org.json.JSONArray

void collapseJson()

It will collapse all nodes, except the main one.

void expandJson()

It will expands all the json nodes.

void setTextColorString(@ColorInt int color)

void setTextColorNumber(@ColorInt int color)

void setTextColorBool(@ColorInt int color)

void setTextColorNull(@ColorInt int color)

Examples 👍

Default view

alt tag