https://github.com/kodedninja/datta
A readable plain text data structure
https://github.com/kodedninja/datta
data data-structures javascript json nodejs
Last synced: 5 months ago
JSON representation
A readable plain text data structure
- Host: GitHub
- URL: https://github.com/kodedninja/datta
- Owner: kodedninja
- License: mit
- Created: 2018-01-14T11:56:43.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-07-31T05:49:51.000Z (about 7 years ago)
- Last Synced: 2025-04-30T10:23:10.251Z (5 months ago)
- Topics: data, data-structures, javascript, json, nodejs
- Language: JavaScript
- Size: 38.1 KB
- Stars: 25
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# datta
A readable plain text structure for strictly formatted data## Installation
```
npm i datta
```## Usage
```javascript
var datta = require('datta')var str = datta.parse(`
ID NAME EMAIL
---
000 RANDOM JOE joe@mail.com
# some comment
001 RANDOM JERRY jerry@mail.com
`)var obj = datta.stringify([
{ ID: 0, NAME: 'RANDOM JOE', EMAIL: 'joe@mail.com' },
{ ID: 1, NAME: 'RANDOM JERRY', EMAIL: 'jerry@mail.com' }
])```
You can also require just a single method:
```javascript
var stringify = require('datta/stringify')
var parse = require('datta/parse')
```## API
### ```stringify(obj)```
Accepts a single ```object```. Returns a ```string```.### ```parse(str)```
Accepts a single ```string```. Returns an ```object```.## Structure
The header contains the names of the fields that are separated by **spaces**. The spaces define the max length of the value.The ```---``` separates the header from the content.
The content forms columns (every field begins where its name is in the header). The last column is basically doesn't have defined length.
Lines beginning with ```#``` are comments.