添加json文件:
"00": "民生银行",
"01": "工商银行",
"02": "中国银行",
"03": "建设银行",
"04": "农业银行",
"05": "交通银行",
"06": "招商银行",
"07": "兴业银行",
"08": "中信银行",
"09": "光大银行",
"10": "平安银行",
"11": "华夏银行"
方法中使用:
let arr = require('../data/bankcode.json')
function findKey(obj, value, compare = (a, b) => a === b) {
return Object.keys(obj).find(k => compare(obj[k], value));
console.log(findKey(arr, "民生银行"));
此时控制台会输出00。
前言 在项目开发的过程中有时候会遇到这种情况:预先定义的对象数组或者json对象,后端返回了一个value值,而你需要用的是key值,后端又没有办法返给你key值,这个时候就需要自己根据value值找key值了。find函数find函数用来查找目标元素,找到就返回该元素,找不到返回undefined数组中使用 定义对象数组:option:[ {text:'+',valu...
This hands-on guide teaches, step by step, how to use JavaScript Object Notation (JSON) with MySQL. Written by a MySQL Community Manager for Oracle, MySQL and JSON: A Practical Programming Guide shows how to quickly get started using JSON with MySQL and clearly explains the latest tools and functions. All content is based on the author’s years of interaction with MySQL professionals. Throughout, real-world examples and sample code guide you through the syntax and application of each method. You will get in-depth coverage of programming with the MySQL Document Store.
•See how JavaScript Object Notation (JSON) works with MySQL
•Use JSON as string data and JSON as a data type
•Find the path, load data, and handle searches with REGEX
•Work with JSON and non-JSON output
•Build virtual generated columns and stored generated columns
•Generate complex geometries using GeoJSON
•Convert and manage data with JSON functions
•Access JSON data, collections, and tables through MySQL Document Store
1 Introduction
MySQL
The Example Database
How to Use This Book
2 JSON as String Data vs. JSON as a Data Type
JSON String Data
The JSON Data Type
3 Finding the Path
Examining the world_x Data
Seeing the Keys
Digging Deeper
4 Finding and Getting Data
All Keys
Searching for a Key
Searching for a Path
Searching for a Value
5 Changing Data
Using Arrays
Appending Arrays
Inserting into an Array
Using TRUNCATE Before Adding New Data
Using JSON_INSERT
Using JSON_REPLACE
JSON_REMOVE
JSON_SET
JSON_UNQUOTE
The Three JSON_MERGE Functions
JSON_MERGE
JSON_MERGE_PRESERVE
JSON_DEPTH
JSON_LENGTH
JSON_TYPE
JSON_VALID
JSON_STORAGE_SIZE
JSON_STORAGE_FREE
6 JSON and Non-JSON Output
JSON-Formatted Data
JSON_OBJECT
JSON_ARRAY
Casting
Non-JSON Output
Missing Data
Nested Data
7 Generated Columns
Using Generated Columns
Columns Generated from JSON
Generated Columns: Common Errors
8 GeoJSON
ST_GeomFromGeoJSON
ST_AsGeoJSON
9 PHP’s JSON Functions
JSON_DECODE
JSON_ENCODE
10 Loading JSON Data
From Download to Database
Step 1: Examine the Data
Step 2: Create the Table
Step 3: Load the Data Using a Wrapper
Step 4: Double-Check the Data
jq: JSON CLI Parser
With No Arguments
Select Certain Fields
The Restaurant Collection
11 The MySQL Document Store
The X DevAPI
mysqlsh
Connections
Session Types
Collections and Documents
CRUD: Create, Replace, Update, Delete
Filtering Find
Sorting
Binding
Indexing Collections
Dropping a Collection
12 Programming with the MySQL Document Store
Programming Examples
Python Example
Node.JS Example
PHP Example
Traditional SQL vs. MySQL Document Store
The MySQL Shell and JavaScript
Relational Tables
Both Relational and Document
Document as Relational
A Additional Resources
Index
JSONFind-一种快速,轻量级的实用程序,可轻松找到大型JSON文件中的值的路径。
JSONFind一个快速,轻量级的实用程序,可以轻松地找到大型JSON文件中的值的路径。
用法可能存在错误,因此欢迎提出问题/请求!
load(url, [data], [callback])
$.get(url, [data], [fn], [type])
$.getJSON(url, [data], [fn])
$.getScript(url, [callback])
$.post(url, [data], [fn], [type])
Ajax 事件
ajaxComplete(callback)
ajaxError(callback)
ajaxSend(callback)
ajaxStart(callback)
ajaxStop(callback)
ajaxSuccess(callback)
$.ajaxSetup([options])
serialize()
serializeArray()
浏览器及特性检测
$.support
$.browser
$.browser.version
$.boxModel
数组和对象操作
$.each(object, [callback])
$.extend([d],tgt,obj1,[objN])
$.grep(array, fn, [invert])
$.makeArray(obj)
$.map(array, callback)
$.inArray(value, array)
$.merge(first, second)
$.unique(array)
$.isArray(obj)
$.isFunction(obj)
字符串操作
$.trim(str)
$.param(obj)
关于jQuery 1.3 版翻译
关于jQuery 1.2 版翻译
提交bug及获取更新
不再维护。 请改为查看 。
JSON查找
该模块的目标是提供对JSON或JSON兼容*值的轻松访问。 这不是用于复杂的JSON查询,而是用于检索特定值而无需不断引用文件的结构。 换句话说,如果您将JSON视为数据库并在同一个文件上进行多个查询,那么这不适合您。 但是,如果您需要从JSON数据中获取信息,例如从合理一致的Web API调用中获取信息,其中数据的结构可能会进行细微的结构更改,那么此模块旨在提供一种方便的方法来访问该数据。
*与JSON兼容的对象意味着该对象的内容只能是:
对象(具有有效JSON)
数组(有效JSON)
/* CommonJS */
const JsonFind = require ( "json-find" ) ;
/* ES6 */
import JsonFind from "json-find" ;
const te
public static String read(String txtName, String apiName) {
txtName = "E:/Diff/" + txtName + ".xls";
// 绝对路径或相对路径都可以,这里是绝对路径,写入文件时演示相对路径
File filename = new File(txtName);
if (!filename.exis...
string StrUtil::map2jsonstrObject(const map<string, Json::Value>& map_info)
Json::Value jObject;
for (map<string, Json::Value>::const_iterator iter = map_info.begin(); iter != map_info.end(); ++iter)
Json::ValueType ...
首先,说一下如何获取form表单中的值:
前提:引入jQuery
<form method="post" enctype='multipart/form-data' id='noteForm'>
<div class="note-type">
<label for="noteTypeList">记事..
load(url, [data], [callback])
$.get(url, [data], [fn], [type])
$.getJSON(url, [data], [fn])
$.getScript(url, [callback])
$.post(url, [data], [fn], [type])
Ajax 事件
ajaxComplete(callback)
ajaxError(callback)
ajaxSend(callback)
ajaxStart(callback)
ajaxStop(callback)
ajaxSuccess(callback)
$.ajaxSetup([options])
serialize()
serializeArray()
浏览器及特性检测
$.support
$.browser
$.browser.version
$.boxModel
数组和对象操作
$.each(object, [callback])
$.extend([d],tgt,obj1,[objN])
$.grep(array, fn, [invert])
$.makeArray(obj)
$.map(array, callback)
$.inArray(value, array)
$.merge(first, second)
$.unique(array)
$.isArray(obj)
$.isFunction(obj)
字符串操作
$.trim(str)
$.param(obj)
关于jQuery 1.3 版翻译
关于jQuery 1.2 版翻译
提交bug及获取更新
理解Vuejs
首先看到的是这么一个定义:Vue.js(读音 /vjuː/, 类似于 view) 是一套构建用户界面的 渐进式框架。与其他重量级框架不同的是,Vue 采用自底向上增量开发的设计。
渐进式框架?自底向上增量开发的设计?
感觉有点新鲜也有点懵逼,于是找到...
思路:截取字符串,但是省份的长度没有规律,比如河南省,比如黑龙江省,还有不是以省结尾的,比如直辖市:上海市,重庆市之类的。
寻找其他规律:我们发现单元格里其实是一个JSON结构,那就好办了
继续观察所有的省份都是在 province 这个key下的
解法:Mid 和 FIND结合
Mid函数用法参照
https://support.microsoft.com/zh-cn/office/mid%e3%80%81midb-%e5%87%bd%e6%9
项目中偶尔会用到解析json,然后获取某个key的值的问题,这个有两个办法,一个是通过json创建一个对象出来,然后通过json转对象,然后通过对象获取对应的value,第二个是通过JsonObject获取对应key的value,但是只能从顶级一层一层的获取你想要的值。
如果json简单,两种方法都可以。如果json复杂一点,两种方法都挺麻烦的,所以就打算自己写一个工具类,通过传进去一个key就能直接获取到value了。
但是有个问题就是如果key有多个重复的话就只能获取到第一个key了,不过这个问题也可以