All Projects → remarkablemark → Reon

remarkablemark / Reon

Licence: mit
🌀 JSON for React.

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to Reon

Easy Mock Server
A mock server for json and mock template files
Stars: ✭ 22 (+120%)
Mutual labels:  json
Kalulu
Uganda Elections Tools and Resources
Stars: ✭ 24 (+140%)
Mutual labels:  json
Android
OwnTracks Android App
Stars: ✭ 840 (+8300%)
Mutual labels:  json
Spray Json
A lightweight, clean and simple JSON implementation in Scala
Stars: ✭ 917 (+9070%)
Mutual labels:  json
Python Ripple Lib
Python client for the Ripple API
Stars: ✭ 23 (+130%)
Mutual labels:  json
Cti Stix Validator
OASIS TC Open Repository: Validator for STIX 2.0 JSON normative requirements and best practices
Stars: ✭ 24 (+140%)
Mutual labels:  json
Sanest
sane nested dictionaries and lists for python
Stars: ✭ 19 (+90%)
Mutual labels:  json
Realm.json.extensions
Extension Methods for adding JSON APIs to a Realm Instance
Stars: ✭ 9 (-10%)
Mutual labels:  json
Forma
Typespec based parsing of JSON-like data for Elixir
Stars: ✭ 23 (+130%)
Mutual labels:  json
Sprachejson
A lightweight, fully-featured JSON parser for C# using Sprache.
Stars: ✭ 7 (-30%)
Mutual labels:  json
Config Rs
⚙️ Layered configuration system for Rust applications (with strong support for 12-factor applications).
Stars: ✭ 915 (+9050%)
Mutual labels:  json
Html Table Cli
Create interactive tables from JSON on the command-line
Stars: ✭ 23 (+130%)
Mutual labels:  json
Swinjectpropertyloader
Swinject extension to load property values from resources
Stars: ✭ 24 (+140%)
Mutual labels:  json
Jkt
Simple helper to parse JSON based on independent schema
Stars: ✭ 22 (+120%)
Mutual labels:  json
Partial.lenses
Partial lenses is a comprehensive, high-performance optics library for JavaScript
Stars: ✭ 846 (+8360%)
Mutual labels:  json
Defiant.js
http://defiantjs.com
Stars: ✭ 907 (+8970%)
Mutual labels:  json
Ps Webapi
(Migrated from CodePlex) Let PowerShell Script serve or command-line process as WebAPI. PSWebApi is a simple library for building ASP.NET Web APIs (RESTful Services) by PowerShell Scripts or batch/executable files out of the box.
Stars: ✭ 24 (+140%)
Mutual labels:  json
Proxy Storage
Provides an adapter for storage mechanisms (cookies, localStorage, sessionStorage, memoryStorage) and implements the Web Storage interface
Stars: ✭ 10 (+0%)
Mutual labels:  json
Cicada
🚀 Fast lightweight HTTP service framework.
Stars: ✭ 851 (+8410%)
Mutual labels:  json
Jose
JSON Object Signing and Encryption for Node.js and the browser
Stars: ✭ 25 (+150%)
Mutual labels:  json

REON NPM version Build Status Coverage Status

NPM

REON (React Element Object Notation) is a data-interchange format inspired by React elements and JSON.

Installation

# npm
npm install reon-core

# yarn
yarn add reon-core

Usage

First import the module:

// ES5
var REON = require('reon-core');

// ES6
import REON from 'reon-core';

REON.stringify()

The REON.stringify() method converts a ReactElement to a JSON string, optionally replacing values if a replacer function is specified.

Syntax:

REON.stringify(ReactElement[, replacer]);

Parameters:

  1. ReactElement (required): The ReactElement to convert to a JSON string.
  2. replacer (optional): A function that alters the behavior of the stringification process.

Examples:

Using REON.stringify():

REON.stringify(
  React.createElement('p', { className: 'classy' }, 'text')
);
// '{"type":"p","props":{"className":"classy","children":"text"}}'

Using the replacer parameter:

REON.stringify(
  React.createElement('p', { className: 'classy' }, 'text'),
  function(key, value) {
    // passing in a replacer parameter will override the default replacer,
    // which removes object keys like `ref`, `_owner`, `_store`
    if (/^ref$|^_.+/.test(key)) return;

    if (value === 'classy') {
      return 'sophisticated'; // return replaced value
    }
    return value; // return everything else unchanged
  }
);
// '{"type":"p","props":{"className":"sophisticated","children":"text"}}'

REON.parse()

The REON.parse() method parses a string as ReactElement, optionally transforming the value producted by parsing.

Syntax:

REON.parse(text[, reviver]);

Parameters:

  1. text (required): The string to parse as ReactElement.
  2. reviver (optional): A function that prescribes how the value originally produced by parsing is transformed, before being returned.

Examples:

Using REON.parse():

REON.parse(
  '{"type":"p","props":{"className":"classy","children":"text"}}'
);
// React.createElement('p', { className: 'classy' }, 'text');

Using the reviver parameter:

REON.parse(
  '{"type":"a","props":{"href":"http://foo.bar","children":"link"}}',
  function(key, value) {
    if (key === 'href' && value === 'http://foo.bar') {
      return 'http://baz.qux'; // return different href
    }
    return value; // return everything else unchanged
  }
);
// React.createElement('a', { href: 'http://baz.qux' }, 'link');

REON.parseObject()

The REON.parseObject() method converts a JavaScript object into ReactElement.

Syntax:

REON.parseObject(object);

Parameters:

  1. object (required): The object to convert into ReactElement.

Examples:

Using REON.parseObject():

REON.parseObject({
  type: 'p',
  props: {
    className: 'classy',
    children: 'text'
  }
});
// React.createElement('p', { className: 'classy' }, 'text');

Testing

# npm
npm test
npm run lint

# yarn
yarn test
yarn run lint

Thanks

To all the contributors.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].