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 ...
随机推荐
- panda2
pandas是python为数据分析建造的可靠工具,很多地方和R语言有想通之处.数据分析并不是工具越高深越好,excel,R,python都是针对不同情况的不同工具,各有各的优缺点,就像你要搭一个架子 ...
- 【转】通过blktrace, debugfs分析磁盘IO
前几天微博上有同学问我磁盘util达到了100%时程序性能下降的问题,由于信息实在有限,我也没有办法帮太大的忙,这篇blog只是想给他列一下在磁盘util很高的时候如何通过blktrace+debug ...
- qt4.8中多线程的几种方式
第一: 用QtConcurrentRun类,适合在另一个线程中运行一个函数.不用继承类,很方便 第二:用QRunnable和QThreadPool结合.继承QRunnable,重写run函数,然后用Q ...
- 028——VUE中事件修饰符once
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- lombok --- 常用注解解析
@Data@Getter @Setter @ToString@Cleanup@NonNull@Builder@EqualsAndHashCode
- SpringInAction--Bean的作用域
Spring定义了多种作用域,我们在使用的时候可以根据使用的需求来选择对应的作用域,这些作用域,包括(第二个括号中为更安全的注解方法,具体更多参数可查看接口代码) 单例(Singleton)(Conf ...
- 配置mysql 允许远程连接
今天折腾了好常时间远程连接mysql ,在云服务器里面打开了3306端口,使用了service mysql status查看到mysql进程正常. netstat -anp | grep mysql ...
- angular 中不要使用location.href
location.href = '#/HKorderList?gid='+gid+'&gname='+encodeURIComponent(gname)+'&cPeriod='+$(' ...
- C#中PadLeft和PadRight小知识点
当我们显示字符串数据时,有时候我们需要考虑数据的排列美观. 比如一些人名和一些编号,我们想让他们整齐对齐显示等. C# String类提供了2种操作方法: String.PadLeft(int tot ...
- 音乐随想——斯美塔那—G小调钢琴协奏曲
乐源 Music -> Piano Trio -> Smetana:Piano Trioin G minor Op.15 总结 每一乐章都会有一段美到极致的主旋律. 第一乐章 起头即有凄凉 ...