1. 项目初始化
yarn  init
yarn add normalizr
项目结构
app.js
package.json
user.json
2. 使用
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"
}
}
]
}
3. 参考文档
https://www.npmjs.com/package/normalizr
https://github.com/rongfengliang/normalizrdemo
 
 
 
 

normalizr api 转换类库使用的更多相关文章

  1. PHP二维码生成的方法(google APi,PHP类库,libqrencode等)

    原文地址: http://blog.csdn.net/liuxinmingcode/article/details/7910975 ================================== ...

  2. streamsets rest api 转换 graphql

    原理很简单,就是使用swagger api 生成schema 然后代理请求处理api 调用 参考项目 https://github.com/rongfengliang/streamsets-graph ...

  3. Json转换类库

    20160605 简单的DaTable转Json private string DtConvertJson(DataTable dt , string modelName="") ...

  4. Delphi 编码转换 Unicode gbk big5(使用LCMapString设置区域后,再用API转换)

    原文:http://blog.dream4dev.com/article.asp?id=17 function UnicodeEncode(Str: string; CodePage: integer ...

  5. 如何使用 window api 转换字符集?

    //宽字符转多字节 std::string W2A(const std::wstring& utf8) { int buffSize = WideCharToMultiByte(CP_ACP, ...

  6. 如何使用 window api 转换字符集?(std::string与std::wstring的相互转换)

    //宽字符转多字节 std::string W2A(const std::wstring& utf8) { int buffSize = WideCharToMultiByte(CP_ACP, ...

  7. MVC web api转换JSON 的方法

  8. Atitit 图像处理之编程之类库调用的接口api cli gui ws rest  attilax大总结.docx

    Atitit 图像处理之编程之类库调用的接口api cli gui ws rest  attilax大总结.docx 1. 为什么需要接口调用??1 1.1. 为了方便集成复用模块类库1 1.2. 嫁 ...

  9. Android原生系统API自带dp、px、sp单位转换

    Android系统中自带的Api中可以使用TypedValue进行单位转换 1,调用系统api转换单位 // 获得转换后的px值 float pxDimension = TypedValue.appl ...

随机推荐

  1. 微信小程序------轮播图

    swiper 微信小程序实现轮播图,和网站,APP的效果差不多,代码少,效率高. 先来看看效果图: 主要用swiper + swiper-item来实现 <view class='swiper' ...

  2. 在阿里云服务器上配置CentOS+Nginx+Python+Flask环境

    在阿里云服务器上配置CentOS+Nginx+Python+Flask环境 项目运行环境 阿里云(单核CPU, 1G内存, Ubuntu 14.04 x64 带宽1Mbps), 具体购买和ssh连接阿 ...

  3. JavaScript---forEach( ) 、map( )和 filter()

    循环数组,最先想到的就是for循环:  for(var i=0;i<count;i++) { //逻辑代码} 除此之外,就是forEach()方法了. Firefox 和Chrome 的Arra ...

  4. Qt 元对象系统(Meta-Object System)

    (转自:http://blog.csdn.net/aladdina/article/details/5496891) Qt的元对象系统基于如下三件事情: 类:QObject,为所有需要利用原对象系统的 ...

  5. gzip压缩解压缩

    压缩/解压缩压缩/解压缩之后的文件名称 必须是gz 解压缩

  6. 【前端安全】 web前端安全编码(模版篇)【转】

    在web的开发的开发过程中,前端总是在处理后端打的各种变量,变量可以包含着中的各种各样的字符,如果不对这些字符进行”特殊“处理的话,轻者导 致页面不正常的显示,潜入了其他的东西,亦即页面挂了,或者弹出 ...

  7. 《Effective C++》第5章 实现-读书笔记

    章节回顾: <Effective C++>第1章 让自己习惯C++-读书笔记 <Effective C++>第2章 构造/析构/赋值运算(1)-读书笔记 <Effecti ...

  8. CDN推送

    一.什么是CDN推送 当后端服务器中的DNS有更新的时候,在varnish的缓存中应该及时地同步后端服务器中的内容.相当于清空varnish中的缓存,当下一次进行访问时,直接从服务器中获取新的内容. ...

  9. Vim使用Vundle管理插件(转)

    转自:http://os.51cto.com/art/201507/484174.htm Vim是Linux上一款用途广泛的轻量级文本编辑工具.虽然对普通的Linux用户来说开始学用起来难度相当大,但 ...

  10. PostgreSQL资料汇总

    慢慢积累一些有用的资料: https://postgrespro.ru