Skip to content

An android JsonViewer to display formatted json with fold/unfold options

License

Notifications You must be signed in to change notification settings

BillCarsonFr/JsonViewer

Repository files navigation

JsonViewer

An android JsonViewer to display formatted json with fold/unfold options

Dependencies

Add this in your root build.gradle at the end of repositories:

	allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}
    implementation 'com.github.BillCarsonFr:JsonViewer:0.6'

This library depends on epoxy

    implementation("com.airbnb.android:epoxy:$epoxy_version")
    kapt "com.airbnb.android:epoxy-processor:$epoxy_version"
    implementation 'com.airbnb.android:mvrx:1.5.1'

Usage

As a dialog

  JSonViewerDialog.newInstance(
                jsonString,
                -1, // open All
                true,
                JSonViewerStyleProvider(
                        keyColor = ...,
                        secondaryColor = ...,
                        stringColor = ...,
                        baseColor = ...,
                        booleanColor = ...,
                        numberColor = ...
                )
        ).show(childFragmentManager, "JSON_VIEWER")

As a fragment in your activity

 val sample = <Your JSON string>
 
        supportFragmentManager.beginTransaction()
            .replace(
                R.id.fragmentContainer,
                JSonViewerFragment.newInstance(
                    sample,
                    initialOpenDepth = -1,
                    wrap = wrap
                ),
                "JSONVIEWER"
            )
            .addToBackStack(null)
            .commit()
            

About

An android JsonViewer to display formatted json with fold/unfold options

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages