Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pateketrueke/json-o-matic
Give super powers to your plain-JSON!
https://github.com/pateketrueke/json-o-matic
Last synced: 10 days ago
JSON representation
Give super powers to your plain-JSON!
- Host: GitHub
- URL: https://github.com/pateketrueke/json-o-matic
- Owner: pateketrueke
- Created: 2013-01-23T19:55:04.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2013-10-26T08:18:04.000Z (about 11 years ago)
- Last Synced: 2024-10-29T11:24:27.014Z (about 2 months ago)
- Language: JavaScript
- Homepage:
- Size: 301 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Yet another JSON-editable solution?
===================================Probably not because here is no validation, no schemas and no complex setup.
Thus **json-o-matic** it's a lot simpler:
```javascript
var data, fields;data = { title: 'Hello World!' };
fields = {
title: { as: 'scalar', label: 'Title:', size: 20 },
status: { as: 'list', label: 'Status:', set: ['draft', 'published'] }
};$('#form-metadata').metadata({ set: fields, use: data });
```You'll get just a field set.
![Sample field](http://i.imgur.com/sK3U7b9.png)
## Available fields and options
Each field type could have its own options, all extra parameters will be passed as html attributes.
All fields accept the **as**, **label** and **invert** parameter by default:
### text
Use textarea element for long text.
Defaults:
- **cols**: 40
- **rows**: 4_Without options._
### scalar
Our usual input type.
Defaults:
- **type**: text
_Without options._
### toggle
Checkbox for toggling states.
Defaults:
- **invert**: `true`
- **set**: `[true, 'true', 'yes', 'on', 1]`Options:
- **set**: List of values to validate the state
### group
Radios or checkboxes nor more nor less.
Defaults:
- **invert**: `true`
- **multiple**: `false`The radio type will be used by default.
Options:
- **multiple**: Use checkboxes to display multiple choices
### list
Just a select element.
Defaults:
- **set**: `[]`
Options:
- **set**: The dropdown options
### hash
Defaults:
- **set**: `{}`
- **add**: `'+'`
- **rm**: `'×'`Options:
- **set**: Dynamic subset of fields
- **add**: Add fields text
- **rm**: Remove field text### map
Defaults:
- **set**: `{}`
Options:
- **set**: Static subset of fields
Afterwards you send the form you'll receive a normal data structure.
```
Array
(
[title] => Hello World!
[status] => draft
)
```That's it!
## Known issues
- Unstyled and not tested cross-browser
- Missing enough documentation## Keep Calm & Contribute
Have issues? Missing features? Share coins?
Sure you rocks!