使用 Newtonsoft 的 SelectToken 取得 Path 節點的內容值,以及 Descendants 拜訪節點
以下的範例我們將使用這個 Json 結構進行說明
JObject o = JObject.Parse(@"{
'Stores': [
'Lambton Quay',
'Willis Street'
#!/usr/bin/env bash | |
# Set up authentication: | |
# apiUrl="https://testnet.binance.vision" | |
apiUrl="https://api.binance.com" | |
apiKey="" | |
secretKey="" | |
# Set up the request: | |
apiMethod="GET" |
input { | |
beats { | |
port => "5044" | |
} | |
} | |
filter { | |
## Ignore the comments that IIS will add to the start of the W3C logs | |
# | |
if [message] =~ "^#" { |
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); |
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'); |
<!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 |