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. linux bash shell中,单引号、 双引号,反引号(``)的区别及各种括号的区别

    一.单引号和双引号 首先,单引号和双引号,都是为了解决中间有空格的问题. 因为空格在Linux中时作为一个很典型的分隔符,比如string1=this is astring,这样执行就会报错.为了避免 ...

  2. nodejs pm2配置使用

    nodejs pm2配置使用教程参考链接:http://www.111cn.net/sys/linux/100927.htm 安装步骤: yum -y install npmnpm install - ...

  3. java和python互相调用

      java和python互相调用  作者:xuaijun  日期:2017.1.1 python作为一种脚本语言,大量用于测试用例和测试代码的编写,尤其适用于交互式业务场景.实际应用中,很多网管系统 ...

  4. vue项目搭建 (一)

    vue项目搭建 (一) 由于一直想要有自己的框架,因而一直在尝试搭建各类结构,结合vue官网及git上大神bailicangdu的项目,再看看网上一些意见,及个人思考,总结的一些,不到之处希望大家可以 ...

  5. c# 让double保留两位小数

    1.Math.Round(0.333333,2);//按照四舍五入的国际标准2.    double dbdata=0.335333;    string str1=String.Format(&qu ...

  6. qt QTableWidget&&QTableView 导出数据到excel

    通常情况下,我们在开发过程中比较常用的方法是将表格的数据到处到excel文件.我也在这个点上头疼了很长时间,不过功夫不负苦心人,最终还是勉强达到效果,为了后面再次用到时不手忙脚乱现在将方法寄存在此,如 ...

  7. h5和app原生联调触发方法

    //路径跳转 urlHref(item) {//人物.访谈.动态是一个页面 var para = {}; para.title = "动态详情"; para.type = &quo ...

  8. zoj1654

    题解: 对于每一联通的x,y 检点 然后交叉的连边 然后二分图 代码: #include<cstdio> #include<cstring> #include<cmath ...

  9. C++11_ Lambda

    版权声明:本文为博主原创文章,未经博主允许不得转载. 这次主要介绍C++11的Lambda语法,一个非常给力的语法 1.组成 : [...导入符号](...参数)mutable(可改写)  throw ...

  10. [置顶] 滴滴插件化VirtualAPK框架原理解析(二)之Service 管理

    在前一篇博客滴滴插件化框架VirtualAPK原理解析(一)之插件Activity管理 中VirtualAPK是如何对Activity进行管理的,本篇博客,我们继续来学习这个框架,这次我们学习的是如何 ...