顯示具有 JSON 標籤的文章。 顯示所有文章
顯示具有 JSON 標籤的文章。 顯示所有文章

2017年8月7日 星期一

Linux 常用資料庫介紹

    表1-1 一些資料庫和緩存伺服器的特性與功能
    名稱
    類型
    資料存儲選項
    查詢類型
    附加功能
    Redis
    使用記憶體存儲(in-memory) 的非關聯式資料庫
    字串、清單、集合、散清單、有序集合
    每種資料類型都有自己的專屬命令, 另外還有批量操作(bulk operation)和不完全(partial)的事務支援
    發佈與訂閱, 主從複製(master/slave replication), 持久化, 腳本(存儲過程,stored procedure)
    memcached
    使用記憶體存儲的鍵值緩存
    鍵值之間的映射
    創建命令、讀取命令、更新命令、刪除命令以及其他幾個命令
    為提升性能而設的多執行緒伺服器
    MySQL
    關聯式資料庫
    每個資料庫可以包含多個表, 每個表可以包含多個行; 可以處理多個表的視圖(view); 支援空間(spatial)和協力廠商擴展
    SELECT 、 INSERT 、 UPDATE 、 DELETE 、函數、存儲過程
    支援ACID性質(需要使用InnoDB), 主從複製和主主複製 (master/master replication)
    PostgreSQL
    關聯式資料庫
    每個資料庫可以包含多個表, 每個表可以包含多個行; 可以處理多個表的視圖; 支援空間和協力廠商擴展;支援可定制類型
    SELECT 、 INSERT 、 UPDATE 、 DELETE 、內置函數、自訂的存儲過程
    支援ACID性質,主從複製, 由協力廠商支援的多主複製 (multi-master replication)
    MongoDB
    使用硬碟存儲(on-disk)的非關係文檔存儲
    每個資料庫可以包含多個表, 每個表可以包含多個無schema (schema-less)的BSON文檔
    創建命令、讀取命令、更新命令、刪除命令、條件查詢命令,等等
    支援map-reduce操作,主從複製,分片, 空間索引(spatial inde

2017年7月5日 星期三

How to form data to JSOM by jQuery funciton HTML JSON form submission

Serialize form data to JSON 

HTML JSON form submission

html <head> include  jquery js code :
 
    <!-- 加载js -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.serializeJSON/2.8.1/jquery.serializejson.min.js">     </script>

then can use methon by JQuery:

  1. var input = $("#inputId").val();
  2. var input = $("form.login").serialize();
  3. var input = $("form.login").serializeArray();
ext:
 $(function(){
        $('.ok').on('click',function(){
            var x = $('#myform').serializeJSON();
            console.log(x);
            var auto = {
                "description": x.description+'^0-0-0-0-0^'+x.sence_list+'^'+x.mac+'^'+'silent',
                "state": x.state,
                "timetable": x.timetable,
                "trigger": x.trigger,
                "action": x.action
                }
            var sdata = JSON.stringify(auto); //json obj to string 
            console.log("send json:  %s",sdata);
            $.post( '/', sdata, function(result) {
                console.log("port return : %j",JSON.parse(result));//result string 2 json 
            });
        })
    })



EXAMPLE 1: Basic Keys
<form enctype='application/json'>
  <input name='name' value='Bender'>
  <select name='hind'>
    <option selected>Bitable</option>
    <option>Kickable</option>
  </select>
  <input type='checkbox' name='shiny' checked>
</form>

// produces
{
  "name":   "Bender"
, "hind":   "Bitable"
, "shiny":  true
}

EXAMPLE 2: Multiple Values
<form enctype='application/json'>
  <input type='number' name='bottle-on-wall' value='1'>
  <input type='number' name='bottle-on-wall' value='2'>
  <input type='number' name='bottle-on-wall' value='3'>
</form>

// produces
{
  "bottle-on-wall":   [1, 2, 3]
}
EXAMPLE 3: Deeper Structure
<form enctype='application/json'>
  <input name='pet[species]' value='Dahut'>
  <input name='pet[name]' value='Hypatia'>
  <input name='kids[1]' value='Thelma'>
  <input name='kids[0]' value='Ashley'>
</form>

// produces
{
    "pet":  {
        "species":  "Dahut"
    ,   "name":     "Hypatia"
    }
,   "kids":   ["Ashley", "Thelma"]
}
EXAMPLE 4: Sparse Arrays
<form enctype='application/json'>
  <input name='hearbeat[0]' value='thunk'>
  <input name='hearbeat[2]' value='thunk'>
</form>

// produces
{
    "hearbeat":   ["thunk", null, "thunk"]
}
EXAMPLE 5: Even Deeper
<form enctype='application/json'>
  <input name='pet[0][species]' value='Dahut'>
  <input name='pet[0][name]' value='Hypatia'>
  <input name='pet[1][species]' value='Felis Stultus'>
  <input name='pet[1][name]' value='Billie'>
</form>

// produces
{
    "pet":  [
        {
            "species":  "Dahut"
        ,   "name":     "Hypatia"
        }
    ,   {
            "species":  "Felis Stultus"
        ,   "name":     "Billie"
        }
    ]
}
EXAMPLE 6: Such Deep
<form enctype='application/json'>
  <input name='wow[such][deep][3][much][power][!]' value='Amaze'>
</form>

// produces
{
    "wow":  {
        "such": {
            "deep": [
                null
            ,   null
            ,   null
            ,   {
                    "much": {
                        "power": {
                            "!":  "Amaze"
                        }
                    }
                }
            ]
        }
    }
}
EXAMPLE 7: Merge Behaviour
<form enctype='application/json'>
  <input name='mix' value='scalar'>
  <input name='mix[0]' value='array 1'>
  <input name='mix[2]' value='array 2'>
  <input name='mix[key]' value='key key'>
  <input name='mix[car]' value='car key'>
</form>

// produces
{
    "mix":  {
        "":     "scalar"
    ,   "0":    "array 1"
    ,   "2":    "array 2"
    ,   "key":  "key key"
    ,   "car":  "car key"
    }
}
EXAMPLE 8: Append
<form enctype='application/json'>
  <input name='highlander[]' value='one'>
</form>

// produces
{
    "highlander":  ["one"]
}

EXAMPLE 9: Files
<form enctype='application/json'>
  <input type='file' name='file' multiple>
</form>

// assuming the user has selected two text files, produces:
{
    "file": [
        {
            "type": "text/plain",
            "name": "dahut.txt",
            "body": "REFBQUFBQUFIVVVVVVVVVVVVVCEhIQo="
        },
        {
            "type": "text/plain",
            "name": "litany.txt",
            "body": "SSBtdXN0IG5vdCBmZWFyLlxuRmVhciBpcyB0aGUgbWluZC1raWxsZXIuCg=="
        }
    ]
}
EXAMPLE 10: Bad input
<form enctype='application/json'>
  <input name='error[good]' value='BOOM!'>
  <input name='error[bad' value='BOOM BOOM!'>
</form>

// Produces:
{
    "error": {
        "good":   "BOOM!"
    }
,   "error[bad":  "BOOM BOOM!"
}
example link form :
https://darobin.github.io/formic/specs/json/#introduction