Skip to main content

Code 2 JSON

A command line utility that can insert code into JSON files and extract code from JSON to insert into a source code file.

Features

  • Create your source code in a separate file and have them be automatically written to JSON with in source markup
  • Write all files in a directory and it's subdirectories to the json
  • Specify the extension of the source code files
  • Specify the delimiter of the identifiers in the source code used to indicate the marked up parts (useful if the language does not support the default delimiter (//)
  • Update the source code based on the source code in the JSON

Planned features

  • A safe mode that allows the user to check the made changes before committing to them

Requirements

  • Python 3: I use print functions in the Python 3 style and I just don't feel like support Python 2 especially since it won't be supported after 2020/01/01
  • (Optionally) Pip: The Python Package Installer can be used to easily install Code 2 JSON but this can also be done by hand

Installation

There are multiple ways to install Code 2 JSON:

Using pip and PyPi

Simply run the following command

pip install code2json

Cloning the repository and installing with pip

  1. Clone the repository
git clone https://gitlab.com/Deathray_II/code2json.git

of if you prefer to use SSH

git clone git@gitlab.com:Deathray_II/code2json.git
  1. go inside the git directory
cd code2json
  1. run pip install on the setup file
pip install .

or if you wish to install it for just your user

pip install --user .

Cloning the repository and manually installing (on Linux)

  1. Clone repository
git clone https://gitlab.com/Deathray_II/code2json.git

of if you prefer to use SSH

git clone git@gitlab.com:Deathray_II/code2json.git
  1. Make accessible in your shell There are two ways to do this either adding an alias or link it into your /usr/bin folder
    • Adding an alias: Got to your ~/.bashrc or ~/.zshrc and add the line alisas code2json=/path/to/cmd.py "$@", where /path/to/cmd.py is the path to the cmd.py file in the src/code2json/ folder in the repository.
    • linking it into your /usr/bin: run (as a user who has access to write in /usr/bin) the command ln -s /path/to/cmd.py /usr/bin/code2json, where /path/to/cmd.py is the path to the cmd.py file in the src/code2json/ folder in the repository.

Usage

If you have cloned the repository you can have a look at the test files and try some of the command on them so you get an idea of how it works

Code to JSON

If we wish to write all the code from a file (apples.c) to the corresponding JSON file we would execute the the following command from the folder that contains our source file

code2json ./apples.c .c 2json

If we wish to write all the .js file underneath the current directory to their JSON file we would run the following command.

code2json . .js 2json

JSON to code

code2json ./apples.c .c 2code
code2json . .js 2json

Metadata

Release files for code2json 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for code2json 0.1.0
File Size Uploaded
code2json-0.1.0.tar.gz 9.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for code2json 0.1.0
File Interpreter ABI Platform
code2json-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 23.3 kB

Release files / code2json-0.1.0.tar.gz

Download URL code2json-0.1.0.tar.gz
Size 9.7 kB
Tags Source
SHA-256 checksum
How to use checksums
72ff8dfa7776261346d6464d87e58a9e33abb6b1e6982e4b880fe2eb393793e3
BLAKE2b-256 checksum
How to use checksums
d642a5b0deb055371b63ac261bb88e06ef88fa61d85cb6be852d7f86d9fbb861
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

Release files / code2json-0.1.0-py3-none-any.whl

Download URL code2json-0.1.0-py3-none-any.whl
Size 13.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
03f22d11904c0fdd92fa1e0deec9ec28a7f1e5a573499187a43d94c7c6cfeee6
BLAKE2b-256 checksum
How to use checksums
6191c8e08f3eb3b142e473e8e6f6f050102ea9bc45dbaf201027ad2e84710571
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page