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 ...
随机推荐
- php7.2版本+yii2会报错
FastCGI sent in stderr: "PHP message: PHP Fatal error: Cannot use 'Object' as class name as it ...
- 【Python】高阶函数介绍
其实函数可以作为变量,之前学过C++,对于这种用法并不奇怪.无非就是函数充当变量,可以传入函数而已. 下面分别介绍 Python 中常见的高阶函数:map/reduce, filter, sorted ...
- day6-面向对象补充篇--类的特殊成员
先说明一下,今天的内容主要转自师兄张其高的博客http://www.cnblogs.com/zhangqigao/articles/6935221.html 前面我们讲了类的方法,有普通方法,就是我们 ...
- Python中面向对象的一些关于私有变量和继承的理解
成员可见性,变量和方法的可见性.使用“__”开头的变量和方法为私有变量和方法 class Student(): def __init__(self, name, age): # 构造函数 # 初始化变 ...
- HDU 3473 Minimum Sum 划分树,数据结构 难度:1
http://acm.hdu.edu.cn/showproblem.php?pid=3473 划分树模板题目,需要注意的是划分树的k是由1开始的 划分树: 参考:http://blog.csdn.ne ...
- 2: 使用Prism初始化程序 Initializing Applications Using the Prism Library 5.0 for WPF(英汉对照版)
This topic addresses what needs to happen to get a Prism for WPF application up and running. A Prism ...
- zoj 2966 Build The Electric System(最小生成树)
Build The Electric System Time Limit: 2 Seconds Memory Limit: 65536 KB In last winter, there wa ...
- Flask数据库常见关系模板代码
常见关系模板代码 以下罗列了使用关系型数据库中常见关系定义模板代码 一对多 示例场景: 用户与其发布的帖子(用户表与帖子表) 角色与所属于该角色的用户(角色表与多用户表) 示例代码 class Rol ...
- SpringMVC札集(04)——SpringMVC传递参数
自定义View系列教程00–推翻自己和过往,重学自定义View 自定义View系列教程01–常用工具介绍 自定义View系列教程02–onMeasure源码详尽分析 自定义View系列教程03–onL ...
- EasyPlayer Android基于ffmpeg实现播放(RTSP/RTMP/HTTP/HLS)同步录像功能
之前有博客专门介绍了EasyPlayer的本地录像的功能,简单来说,EasyPlayer是一款RTSP播放器,它将RTSP流里的音视频媒体帧解析出来,并用安卓系统提供的MediaMuxer类进行录像. ...