Giter Club home page Giter Club logo

dirtyjson's Introduction

dirty-json python wrapper

A python wrapper for this amazing NodeJS application https://github.com/RyanMarcus/dirty-json

Installation

  1. Be sure to have node installed on your machine (otherwise go to https://nodejs.org/en/download/)
  2. Install the node requirements: npm install
  3. Install the Python requirements: pip install -r requirements.txt

Running python wrapper

import py_wrapper
import json

# ... have the broken string
string = '{something: ""very" broken"}'
fixed_string = py_wrapper.fix_json(string)

json.loads(fixed_string)

Docker container

It would be nice to run as a REST webservice, to avoid language dependency.

This needs some few files / prebuilt docker image

docker build -t martinomensio/dirtyjson .

docker run -dit --name dirtyjson-rest -p 12345:12345 martinomensio/dirtyjson

Or from the docker hub (same command)

docker run -dit --name dirtyjson-rest -p 12345:12345 martinomensio/dirtyjson

Run a request to the microservice:

curl -X POST \
  http://localhost:12345 \
  -H 'Content-Type: text/plain' \
  -d '{broken:json}'

or in python:

import requests
requests.post('http://localhost:12345', data='{broken:json}', headers={'content-type': 'text/plain'}).json()

Suggestion

This has a bit of latency, just run the requested when you are sure your JSON is broken (e.g. in the catch/except).

dirtyjson's People

Contributors

martinomensio avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

surepassio

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.