All Projects → raul1991 → Diver.js

raul1991 / Diver.js

Licence: mit
Dives deep into the dom and dumps it in the object literal notation.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Diver.js

Ws
⚠️ Deprecated - (in favour of Networking) ☁️ Elegantly connect to a JSON api. (Alamofire + Promises + JSON Parsing)
Stars: ✭ 352 (+517.54%)
Mutual labels:  rest-api, json
Spyke
Interact with REST services in an ActiveRecord-like manner
Stars: ✭ 591 (+936.84%)
Mutual labels:  rest-api, json
Node Rest Client
REST API client from node.js
Stars: ✭ 365 (+540.35%)
Mutual labels:  rest-api, json
Spine
A Swift library for working with JSON:API APIs. It supports mapping to custom model classes, fetching, advanced querying, linking and persisting.
Stars: ✭ 267 (+368.42%)
Mutual labels:  rest-api, json
Rest Api Examples
Test and Prototype with Fake Online REST/OAuth 2 APIs Examples
Stars: ✭ 13 (-77.19%)
Mutual labels:  rest-api, json
Imbo
Imbo is an image "server" that can be used to add/get/delete images using a RESTful interface.
Stars: ✭ 312 (+447.37%)
Mutual labels:  rest-api, json
Networking
⚡️ Elegantly connect to a REST JSON Api. URLSession + Combine + Decodable + Generics = <3
Stars: ✭ 499 (+775.44%)
Mutual labels:  rest-api, json
Iotwifi
Raspberry Pi (arm) wifi configuration container. Configure and control wifi connectivity with a JSON based REST api.
Stars: ✭ 236 (+314.04%)
Mutual labels:  rest-api, json
Restclient
🦄 Simple HTTP and REST client for Unity based on Promises, also supports Callbacks! 🎮
Stars: ✭ 675 (+1084.21%)
Mutual labels:  rest-api, json
Ulfius
Web Framework to build REST APIs, Webservices or any HTTP endpoint in C language. Can stream large amount of data, integrate JSON data with Jansson, and create websocket services
Stars: ✭ 666 (+1068.42%)
Mutual labels:  rest-api, json
Safrs
SqlAlchemy Flask-Restful Swagger Json:API OpenAPI
Stars: ✭ 255 (+347.37%)
Mutual labels:  rest-api, json
Generator Http Fake Backend
Yeoman generator for building a fake backend by providing the content of JSON files or JavaScript objects through configurable routes.
Stars: ✭ 49 (-14.04%)
Mutual labels:  rest-api, json
Httpie
As easy as /aitch-tee-tee-pie/ 🥧 Modern, user-friendly command-line HTTP client for the API era. JSON support, colors, sessions, downloads, plugins & more. https://twitter.com/httpie
Stars: ✭ 53,052 (+92973.68%)
Mutual labels:  rest-api, json
Kim
Kim: A JSON Serialization and Marshaling framework
Stars: ✭ 326 (+471.93%)
Mutual labels:  rest-api, json
Http Fake Backend
Build a fake backend by providing the content of JSON files or JavaScript objects through configurable routes.
Stars: ✭ 253 (+343.86%)
Mutual labels:  rest-api, json
Laravel Api Response Builder
Builds nice, normalized and easy to consume Laravel REST API JSON responses.
Stars: ✭ 433 (+659.65%)
Mutual labels:  rest-api, json
Datoji
A tiny JSON storage service. Create, Read, Update, Delete and Search JSON data.
Stars: ✭ 222 (+289.47%)
Mutual labels:  rest-api, json
Play Scala Rest Api Example
Example Play Scala application showing REST API
Stars: ✭ 227 (+298.25%)
Mutual labels:  rest-api, json
Rest Assured
Java DSL for easy testing of REST services
Stars: ✭ 5,646 (+9805.26%)
Mutual labels:  rest-api, json
Snmpbot
Golang SNMP library + SNMP REST API
Stars: ✭ 44 (-22.81%)
Mutual labels:  rest-api, json

diver.js

Dives deep into the DOM and dumps it as a js object.

What does it do ?

Creating a rest based app requires you to send data to your server in json or xml (most likely). Well you know when the data is huge on the client side you tend to create the json yourself most of the time by writing a lot of boiler plate code. What if you just had to tweak in your html and the hierarchical json with the values would be created magically for you. Interesting ?

So basically diver does all that for you.

How it works ?

It works by accepting a root-node-id and an empty object. Now it traverses the complete tree and translates every leaf node having a name into its corresponding object literal notation. The name of the leaf node would be translated into an object key and its value will be that key's value. It is important to note that "Select" html element is an exception to the aforementioned criteria. The name attribute on the select element will be taken as the key and the selected option would be taken as it's value.

Terminologies

Read more about the terms used in this repository on the wiki page

Attributes supported by the library

Attribute Value Use With Output Type
group path.to.your.json.property Any non-container html element like h1..h6, p, input(preferably) etc. Any element which will have child elements inside it won't work like table, div etc. string
delimiter Any token that separates the input value. input - Html Element javascript array []
name Any valid object key Any non-container html element like h1..h6, p, input(preferably) etc. Any element which will have child elements inside it won't work like table, div etc. string

How to use it ?

Include the script

<script type="text/javascript" src="diver.js"></script>

Example Html

<div id="container-top" style="margin:10%">
    <div>
        <div style="margin-left: -118px">
            <label for="inputName">Name</label>
            <div>
                <input  type="text"  name="first_name" group="personal_details" placeholder="First"
                value="cafebabe">
                <input  type="text"  name="last_name"  group="personal_details" placeholder="Last"
                value="1991">
            </div>
        </div>
        <div style="margin-left: -118px">
            <label for="inputAge">Age</label>
            <div>
                <input type="text"  name="age" group="personal_details.age" placeholder="Age" value="21">
            </div>
        </div>
        <div style="margin-left: -118px">
            <label for="inputEmail">Email</label>
            <div>
                <input type="text" group="personal_details.email" name="email_id"  placeholder="Email" value="[email protected]">
                <input type="checkbox" group="personal_details" name="isChecked">
                <input type="text" name="values" delimiter="," placeholder="delimited values" value="foo,bar,john-doe">
                <select name="cars">
                    <option>Lamborghini</option>
                    <option>Porsche</option>
                    <option>Maybach</option>
                </select>
            </div>
        </div>
    </div>
</div>

Example call to the diver's function

var obj = diver.traverse('container-top',{});

Output

Input fields with no value will not be dumped for example 'isChecked'

{
"personal_details": {
   "first_name": "cafebabe",
   "last_name": "1991",
   "values":["foo","bar","john-doe"],
   "age": {
     "age": "21"
   },
   "email": {
     "email_id": "[email protected]"
    }
},
"cars": "Lamborghini"
}
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].