使用 Newtonsoft 的 SelectToken 取得 Path 節點的內容值,以及 Descendants 拜訪節點
以下的範例我們將使用這個 Json 結構進行說明
JObject o = JObject.Parse(@"{
'Stores': [
'Lambton Quay',
'Willis Street'
function queryStringToJson(s="") | |
{ | |
return JSON.parse(s.replace(/[?|&]([A-Za-z0-9]*)=([^&]*)/ig, ",\"$1\":\"$2\"").slice(1).replace(/(.*)/, "{ $1 }")); | |
} |
/*----------------------------------------------------*/ | |
/* MOBILE DETECT FUNCTION | |
/*----------------------------------------------------*/ | |
var isMobile = { | |
Android: function() { | |
return navigator.userAgent.match(/Android/i); | |
}, | |
BlackBerry: function() { | |
return navigator.userAgent.match(/BlackBerry/i); |
/** | |
* @description jQuery-scroll-bottom。 | |
* | |
* 指定 selector 如果有捲軸時,當滑動至底部時觸發事件 | |
* @module ScrollBottom | |
* @author 許益銘 <mufasa.hsu@gmail.com> | |
* @example | |
* require('./jquery-scroll-bottom'); | |
* | |
* // method 1 |
function ParsedUrl(url) { | |
this.parse(url); | |
} | |
ParsedUrl.prototype.parse = function (url) { | |
var parser = document.createElement("a"); | |
parser.href = url; | |
// IE 8 and 9 dont load the attributes "protocol" and "host" in case the source URL | |
// is just a pathname, that is, "/example" and not "http://domain.com/example". |
'use strict'; | |
// Modules | |
var webpack = require('webpack'); | |
var autoprefixer = require('autoprefixer'); | |
var HtmlWebpackPlugin = require('html-webpack-plugin'); | |
var ExtractTextPlugin = require('extract-text-webpack-plugin'); | |
var CopyWebpackPlugin = require('copy-webpack-plugin'); | |
var _ = require('lodash'); |
歡迎加入我的 LINE ID: easter1021
在網路上參考幾份文件,最終選擇使用 Sergey Metlov 的範例,以下內容是我實作時遇到的問題以及詳解。
此篇文章執行的作業系統為
Windows 7
學習時間 10 分鐘
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>demo serializeArray of form to json object</title> | |
<script type="text/javascript" src="main.js"></script> | |
</head> | |
<body> | |
<form> | |
<input type="text" name="desc" value="demo serializeArray of form to json object."> | |
<input type="text" name="users[0].name" value="user A"> |
let _ = require('lodash'); | |
//Input | |
var input = [ | |
{ key: '1', val: 'a' }, | |
{ key: '2', val: 'b' }, | |
{ key: '3', val: 'c' } | |
]; | |
//Desired output |
/** | |
* 這檔案是參考 https://forums.xamarin.com/discussion/21298/entrycell-password 並加以修正。 | |
* 主要是 xamarin 目前暫無密碼輸入的 EntryCell, | |
* | |
* 我增加的部份: | |
* 1. 建立 BindableProperty 讓 XAML 也可以使用 Value 屬性 | 2017.04 | |
*/ | |
using System; | |
using Xamarin.Forms; |