normalizr api 转换类库使用
yarn init
yarn add normalizr
项目结构
app.js
package.json
user.json
a. app.js
const userjson = require("./user.json");
const { normalize, schema } = require('normalizr');
// Define a users schema
const user = new schema.Entity('users');
// Define your comments schema
const comment = new schema.Entity('comments', {
commenter: user
});
// Define your article
const article = new schema.Entity('articles', {
author: user,
comments: [ comment ]
});
const normalizedData = normalize(userjson, article);
console.log(normalizedData)
b. package.json
{
"name": "normalizrapp",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"normalizr": "^3.2.4"
}
}
c. user.json
{
"id": "123",
"author": {
"id": "1",
"name": "Paul"
},
"title": "My awesome blog post",
"comments": [
{
"id": "324",
"commenter": {
"id": "2",
"name": "Nicole"
}
}
]
}
https://www.npmjs.com/package/normalizr
https://github.com/rongfengliang/normalizrdemo
normalizr api 转换类库使用的更多相关文章
- PHP二维码生成的方法(google APi,PHP类库,libqrencode等)
原文地址: http://blog.csdn.net/liuxinmingcode/article/details/7910975 ================================== ...
- streamsets rest api 转换 graphql
原理很简单,就是使用swagger api 生成schema 然后代理请求处理api 调用 参考项目 https://github.com/rongfengliang/streamsets-graph ...
- Json转换类库
20160605 简单的DaTable转Json private string DtConvertJson(DataTable dt , string modelName="") ...
- Delphi 编码转换 Unicode gbk big5(使用LCMapString设置区域后,再用API转换)
原文:http://blog.dream4dev.com/article.asp?id=17 function UnicodeEncode(Str: string; CodePage: integer ...
- 如何使用 window api 转换字符集?
//宽字符转多字节 std::string W2A(const std::wstring& utf8) { int buffSize = WideCharToMultiByte(CP_ACP, ...
- 如何使用 window api 转换字符集?(std::string与std::wstring的相互转换)
//宽字符转多字节 std::string W2A(const std::wstring& utf8) { int buffSize = WideCharToMultiByte(CP_ACP, ...
- MVC web api转换JSON 的方法
- Atitit 图像处理之编程之类库调用的接口api cli gui ws rest attilax大总结.docx
Atitit 图像处理之编程之类库调用的接口api cli gui ws rest attilax大总结.docx 1. 为什么需要接口调用??1 1.1. 为了方便集成复用模块类库1 1.2. 嫁 ...
- Android原生系统API自带dp、px、sp单位转换
Android系统中自带的Api中可以使用TypedValue进行单位转换 1,调用系统api转换单位 // 获得转换后的px值 float pxDimension = TypedValue.appl ...
随机推荐
- go-statsd项目
linux命令: 进程:top 收包丢包:netstat -su[c持续输出] go tool pprof: 我们可以使用go tool pprof命令来交互式的访问概要文件的内容.命令将会分析指定的 ...
- Web应用体系结构
容器 Servlet没有main()方法,它们受控于另一个Java应用,这个Java应用称为容器(Container).我们最常见的tomcat就是这样一个容器. Web服务器应用(如Apache)得 ...
- layui弹窗宽度固定高度自适应界面
//默认上下15px的边距高度,可根据需要修改function layuiDialogFitScreen(){ var layui_title_height=$(window.parent.docum ...
- nyoj762——分解质因数+容斥+二分
第k个互质数 时间限制:1000 ms | 内存限制:65535 KB 难度:4 描述 两个数的a,b的gcd为1,即a,b互质,现在给你一个数m,你知道与它互质的第k个数是多少吗?与m互质的 ...
- 无密码登陆的ssh和ssh-agent
原文地址:http://lxshopping.blog.51cto.com/4542643/1179864/ 一,不需要输密码的ssh 原理:首先服务器端把公钥传给Client端,Client端在验证 ...
- echarts 折线图配置
html内容: <div id="user_num_chart" style="width: 582px;height:250px;"></d ...
- 华为EPON OLT开局配置
配置思路: 1. 登录olt(console进去之后配地址) 2.配置上联口(配vlan和起三层地址互联路由的lan口) 3.epon接分光器,分光器下接光猫 4.自动发现光猫.配置DBA数据和线 ...
- json与api- 天气api 博客词频分析
一.json基础 1.1 json的介绍 json现在成为各种程序与语言之间交互的一种数据格式,本质是文本,字符串. json有两种格式: 1. 类似字典 {k:v,k,v} 2. 类似列表 { ...
- nodejs编译sass模块包 node-compass,与gulp包gulp-sass使用方法
简介:node express或者就是node项目中,要自动编译sass方法很多,比如gulp 比如考拉,比如今天我想说的这个包node-compass. 编译sass的三种方法: 前提条件: 都需要 ...
- easyUI---分页插件
设置 //分页组件 $('#detailLayer .detailPag').pagination({ pageNumber: 1, pageSize: 10, total: result.Total ...