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 nnlpy

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.4.0.tar.gz (6.4 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.4.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for nnlpy-0.4.0.tar.gz
Algorithm Hash digest
SHA256 f56ea4a98bf3f875434022184f9b9e205753a339b2feeb1878c6c90820d9a605
MD5 3ceac66e6e4c28059092e3e34692d9eb
BLAKE2b-256 1824b8e436ac8f0897e68d41d73cba0c44cd60177ebc9f9b11e0d38dff35ca56

See more details on using hashes here.

File details

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

File metadata

  • Download URL: nnlpy-0.4.0-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.10.19

File hashes

Hashes for nnlpy-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7b03668e27eaf1b5cafe4b69be9fee581c3f1ab01d75471f8408bf17a85ff08f
MD5 a637d2bd4d8097bb75638ef73510d6c4
BLAKE2b-256 2817033e22f721d5cb237c669bd7626e5cc73f374d589491757e2e437026fe5d

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