简体   繁体   English

Json Diff补丁Javascript-extjs

[英]Json Diff Patch Javascript - extjs

Well I put my great effort to solve my problem so in the end I finally end up here posting a question 好吧,我竭尽全力解决我的问题,所以最终我最终在这里发布了一个问题

I want to show my JSON diff like this in the given link below https://neil.fraser.name/software/diff_match_patch/svn/trunk/demos/demo_diff.html 我想在https://neil.fraser.name/software/diff_match_patch/svn/trunk/demos/demo_diff.html下面的给定链接中显示这样的JSON差异

Here is the documentation of the given Library https://code.google.com/p/google-diff-match-patch/ 这是给定库https://code.google.com/p/google-diff-match-patch/的文档

Any one have idea how to used it an Sencha Extjs to display diff between two JSON objects 任何人都知道如何使用Sencha Extjs来显示两个JSON对象之间的差异

you might want to look at jsondiffpatch (disclaimer: I'm the author), 您可能想看一下jsondiffpatch (免责声明:我是作者),

you can try it online here , just some highlights: 您可以在这里在线试用 ,仅需注意以下几点

  • a smart array diff (uses LCS to detect adds/removes, and finds item moved in arrays) 智能数组差异(使用LCS来检测添加/删除,并找到在数组中移动的项目)
  • it's pretty customizable, you can even write plugins to change any part of diff/patch mechanism 这是非常可定制的,您甚至可以编写插件来更改diff / patch机制的任何部分
  • if 2 long strings are found anywhere in the graph, it will use the Neil Fraser's lib you mention internally to get a text unidiff 如果在图中的任意位置找到2个长字符串,它将使用您内部提到的Neil Fraser的lib来获取文本unidiff
  • multiple formatters, html (the one used at the online demo), console, annotated, and now jsonpatch (RFC6902) 多种格式化程序,html(在线演示中使用的一种),控制台,带注释的和现在的jsonpatch(RFC6902)

this should work for diffing/patching any 2 objects, framework agnostic, if ExtJS defines special private properties on your objects, you can ignore them specifying a propertyFilter 这应该适用于与框架无关的两个对象的区分/修补,如果ExtJS在对象上定义了特殊的私有属性,则可以通过指定propertyFilter忽略它们

https://www.npmjs.com/package/deep-diff https://www.npmjs.com/package/deep-diff

We use it - it's great - example: 我们使用它-非常好-例如:

var diff = require('deep-diff').diff;

var lhs = {
    name: 'my object',
    description: 'it\'s an object!',
    details: {
        it: 'has',
        an: 'array',
        with: ['a', 'few', 'elements']
    }
};

var rhs = {
    name: 'updated object',
    description: 'it\'s an object!',
    details: {
        it: 'has',
        an: 'array',
        with: ['a', 'few', 'more', 'elements', { than: 'before' }]
    }
};

var differences = diff(lhs, rhs);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM