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 ...
随机推荐
- sqlserver存储过程杀掉数据库中死锁
Create proc p_lockinfo @kill_lock_spid bit=1, --是否杀掉死锁的进程,1 杀掉, 0 仅显示 @show_spid_if_nolock ...
- C++(二十七) — 深拷贝、浅拷贝、复制构造函数举例
1.复制构造函数.及new空间申请 复制构造函数,也是构造函数.只在初始化时调用,如果定义对象后赋值,比如,t1=t2,则只是运算符重载,没有调用构造函数. #include <iostream ...
- Reverse a String
题目: 翻转字符串 先把字符串转化成数组,再借助数组的reverse方法翻转数组顺序,最后把数组转化成字符串. 你的结果必须得是一个字符串 这是一些对你有帮助的资源: Global String Ob ...
- py-faster-rcnn:在windows上配置
0.先说一下本机配置 opencv2+cuda7.5+cudnn+anaconda,这些基础的之前都是配置好了的,python环境建议使用anaconda,用到的库基本都有了,好像没有easydict ...
- 【LeetCode-128】Longest Consecutive Sequence
描述 输入一个乱序的连续数列,输出其中最长连续数列长度,要求算法复杂度为 O(n) . 输入 54,55,300,12,56 输出 3 通常我们看有没有连续序列时 找某个数有没有的前后的数,比如看到5 ...
- 【微软混合现实】开始使用Unity-第一章:创建一个新的项目
使用Unity开发App,第一步需要创建一个项目.项目具有一系列组织好文件夹,其中最重要的是你的附件文件夹(Assets folder).在这个文件夹中,存储了从其他工具中创建的数字内容,比如Maya ...
- springcloud- FeginClient 调用统一拦截添加请求头 RequestInterceptor ,被调用服务获取请求头
使用场景: 在springcloud中通过Fegin调用远端RestApi的时候,经常需要传递一些参数信息到被调用服务中去,比如从A服务调用B服务的时候, 需要将当前用户信息传递到B调用的服务中去,我 ...
- New Concept English three(17)
27W/m 65 Verrazano, an Italian about whom little is known, sailed into New York Harbour in 1524 and ...
- 日尼玛(。・∀・)ノ゙嗨 关于使用netstat时:::*
关于使用netstat时 # netstat -tlnp | grep :22 tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1444/sshd tcp6 0 0 :::22 ...
- gradle-wrapper.properties中各属性的含义
gradle-wrapper.properties中各属性的含义 1. gradle-wrapper.properties 每一个用gradle编译的工程,都会有一个gradle\wrapper目录. ...