Skip to main content

NNL parser/serializer - Near Natural Language (JSON-capable)

Project description

NNL โ€” Near Natural Language

A Human-Readable, JSON-Compatible Data Language

Status Python License


๐ŸŒฑ What is NNL?

NNL (Near Natural Language) is a human-friendly, indentation-based data notation that looks like simple English sentences but maps 1:1 to JSON.

Write this:

user contains:
name is Alice.
age is 30.
roles are admin, editor.

And get this JSON:

{
  "user": {
    "name": "Alice",
    "age": 30,
    "roles": ["admin", "editor"]
  }
}

NNL is perfect for:

  • Configuration files
  • API payloads
  • Human-editable datasets
  • Documentation / examples
  • Structured content

โœจ Features

  • Full JSON compatibility

  • Human-readable, minimal punctuation

  • Natural English-like syntax

  • Supports:

    • objects (contains:)
    • arrays (are:)
    • inline lists (a, b, c)
    • arrays of objects
    • nested structures
    • numbers, strings, booleans, null
  • Round-trip safe (NNL โ†’ JSON โ†’ NNL)


๐Ÿ”ง Installation

After publishing to PyPI:

pip install nnl

Local development install:

pip install -e .

๐Ÿงช Usage (Python)

from nnl import parse_nnl, dump_nnl

text = """
user contains:
  name is Alice.
  age is 22.
  roles are admin, editor.
"""

data = parse_nnl(text)
print(data)
# {'user': {'name': 'Alice', 'age': 22, 'roles': ['admin', 'editor']}}

print(dump_nnl(data))

๐Ÿ“ CLI Usage

After install, the command nnl becomes available:

NNL โžœ JSON

nnl nnl2json file.nnl

Or via stdin:

type file.nnl | nnl nnl2json -

JSON โžœ NNL

nnl json2nnl file.json

๐Ÿ“š Language Basics

Objects

project contains:
  name is Atlas.
  version is 1.0.

Inline Lists

tags are alpha, beta, gamma.

Block Lists

items are:
  - apple.
  - banana.
  - cherry.

Arrays of Objects

users are:
  - contains:
      id is 1.
      name is Alice.
  - contains:
      id is 2.
      name is Bob.

Nested Lists (Matrices)

matrix are:
  - 1, 2, 3.
  - 4, 5, 6.

๐Ÿ“„ Documentation

See the docs directory:

  • spec.md โ€” Official NNL Specification v1.0
  • examples.md โ€” Practical examples & patterns

๐Ÿงช Testing

Run the test suite:

pytest -q

๐Ÿ”จ Development

Install dependencies

pip install -e . pytest

Project Structure

nnl/
 โ”œโ”€โ”€ nnl/
 โ”‚    โ”œโ”€โ”€ __init__.py
 โ”‚    โ”œโ”€โ”€ core.py
 โ”‚    โ”œโ”€โ”€ cli.py
 โ”œโ”€โ”€ tests/
 โ”‚    โ”œโ”€โ”€ test_nnl_basic.py
 โ”œโ”€โ”€ docs/
 โ”‚    โ”œโ”€โ”€ spec.md
 โ”‚    โ”œโ”€โ”€ examples.md
 โ”œโ”€โ”€ example.nnl
 โ”œโ”€โ”€ pyproject.toml
 โ”œโ”€โ”€ README.md
 โ”œโ”€โ”€ LICENSE
 โ”œโ”€โ”€ CONTRIBUTING.md

๐Ÿš€ Publishing (PyPI)

Build:

python -m build

Upload:

twine upload dist/*

๐Ÿค Contributing

Pull requests and issues are welcome. NNL is designed to be readable, stable, and easy to extend.


๐Ÿ“œ License

MIT License See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nnlpy-0.3.1.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nnlpy-0.3.1-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file nnlpy-0.3.1.tar.gz.

File metadata

  • Download URL: nnlpy-0.3.1.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for nnlpy-0.3.1.tar.gz
Algorithm Hash digest
SHA256 c80a7821c593cc80032c76c98319813fad444f5148423b39e1583fcc75db2222
MD5 69406fa051be50332b80b62380c601bd
BLAKE2b-256 ebb38be538defcd1a12c3e3895a319c07b7b4d30c14dc89a2e32520334ddd60f

See more details on using hashes here.

File details

Details for the file nnlpy-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: nnlpy-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for nnlpy-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cf1d5c468656cee3bbd3f117e0d95dcb46b9df73794af7d5a310a3e9f03fb77e
MD5 ea6095783e82dd4e889cb29592ee181d
BLAKE2b-256 e85d1e6a22bd96b17b493e47f7011e4d7961e79cb733220e1ef6ffdb2a725c8b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page