GithubHelp home page GithubHelp logo

human-json's Introduction

Build Status

Human JSON

human_json is a simple python library, that can take a JSON Object, and create a pretty string for that object.

JSON is easy to transport, and quite easy to read, but requires some form of prior training to properly understand it. This library allows one to transform JSON Objects into an easier to read format

Example

The following Python dictionary (which can represent a JSON Object):

{
    'className': 'ComputerScience',
    'classId': 2020,
    'assignments': {
        'assignment1': {
            'average_grade': 5.5,
            'description': 'Complete Assignment 1',
            'grades': [5, 5, 5, 7]
        },
        'assignment2': {
            'average_grade': None,
            'description': 'Complete Assignment 2',
            'grades': ()
        }
    },
    'students': ('student1', 'student2', 'studentabc', 2019, None, 10.5),
}

turns into the following pretty string:

className: ComputerScience
classId: 2020
assignments:
	assignment1:
		average_grade: 5.5
		description: Complete Assignment 1
		grades:
			5
			5
			5
			7
	assignment2:
		average_grade: None
		description: Complete Assignment 2
		grades:
			-
students:
	student1
	student2
	studentabc
	2019
	None
	10.5

Custom Prefixes

You can also specify an optional prefix, that will be prefixed to each line. A possible prefix is "* ". Using this prefix, will return a markdown list. This can be directly copy-pasted into a markdown file, for example:

* className: ComputerScience
* classId: 2020
* assignments:
	* assignment1:
		* average_grade: 5.5
		* description: Complete Assignment 1
		* grades:
			* 5
			* 5
			* 5
			* 7
	* assignment2:
		* average_grade: None
		* description: Complete Assignment 2
		* grades:
			* -
* students:
	* student1
	* student2
	* studentabc
	* 2019
	* None
	* 10.5

Custom Indentations

You can also specify a custom indentation. The default is "\t", but you can specify " " or even a number of spaces. Below is an example using 2:

className: ComputerScience
classId: 2020
assignments:
  assignment1:
    average_grade: 5.5
    description: Complete Assignment 1
    grades:
      5
      5
      5
      7
  assignment2:
    average_grade: None
    description: Complete Assignment 2
    grades:
      -
students:
  student1
  student2
  studentabc
  2019
  None
  10.5

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.