lukascivil / json-difference Goto Github PK
View Code? Open in Web Editor NEWA simple way to find the difference between two objects or json diff
Home Page: https://lukascivil.github.io/json-difference/
License: MIT License
A simple way to find the difference between two objects or json diff
Home Page: https://lukascivil.github.io/json-difference/
License: MIT License
Would you consider optionally providing the diff in a format compatible with JSON Patch (RFC 6902) ?
I have a Nuxt2 project and I installed and tested the library locally. Things seemed to work perfectly. But when I build my project, I get the following error(s):
ERROR Failed to compile with 1 errors friendly-errors 18:56:37
ERROR in ./node_modules/json-difference/dist/index.js friendly-errors 18:56:37
Module parse failed: Unexpected token (1:1247) friendly-errors 18:56:37
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=(e,f)=>{const o=[];for(const i in e)if(f.hasOwnProperty(i)){if(typeof e[i]=="object"&&typeof f[i]=="object"&&JSON.stringify(e[i])===JSON.stringify(f[i])||e[i]===f[i])continue;if(e[i]==="@{}"||e[i]==="@[]"){const n=f[i]==="@{}"?{}:f[i]==="@[]"?[]:f[i];e[i]==="@{}"?JSON.stringify(f[i])!=="{}"&&o.push([i,{},n]):JSON.stringify(f[i])!=="[]"&&o.push([i,[],n])}else o.push([i,e[i],f[i]])}return o},p=(e,f)=>{const o=[];let i=0;for(const n in e)if(!(n in f)){const r=e[n]==="@{}"?{}:e[n]==="@[]"?[]:e[n];o[i]=[n,r],i++}return o},O=(e,f,o,i)=>{const n=i?e?"[":".":"/",r=i?e?"]":"":e?"[]":"";return f==="__start__"?`${i&&e?"[":""}${o}${r}`:`${f}${n}${o}${r}`},s=(e,f=!1,o,i="__start__")=>{o===void 0&&(o=Array.isArray(e)?{__root__:"@[]"}:{__root__:"@{}"});for(const n of Object.keys(e)){const r=O(Array.isArray(e),i,n,f);typeof e[n]=="object"&&e[n]!==null?(Object.keys(e[n]).length===0?o[r]=e[n]:o[r]=Array.isArray(e[n])?"@[]":"@{}",s(e[n],f,o,r)):o[r]=e[n]}return o},c=e=>(e.edited=e.edited.filter(f=>!(typeof f[1]=="object"&&f[2]==="@{}")).map(f=>f[2]==="@{}"?[f[0],f[1],{}]:f[2]==="@[]"?[f[0],f[1],[]]:f),e),b={isLodashLike:!1},j=(e,f,o)=>{const{isLodashLike:i}=o??b,n={added:[],removed:[],edited:[]},r=typeof e=="string"?JSON.parse(e):e,_=typeof f=="string"?JSON.parse(f):f,y=s(r,i),g=s(_,i);return n.removed=p(y,g),n.added=p(g,y),n.edited=t(y,g),c(n)};exports.getDiff=j;exports.getEditedPaths=t;exports.getPathsDiff=p;exports.getStructPaths=s;
|
Node version is 20.
I don't see any module importing from vite in the source of json-difference. It helps the downstream projects to exclude the vite as a transit dependency.
The https://rawgit.com/lukascivil/jsondiffer/master/dist.browser/json-difference.mjs link mentioned in the README "Installation" section is broken. I'm guessing this it just the result of the broken workflow.
As a workaround, I'm using a non-master
link like https://rawgit.com/lukascivil/json-difference/1.9.1/dist.browser/json-difference.mjs.
Hi,
I'd like to understand if something is the normal behavior of this module or if this is a bug.
Getting a diff using something like this:
getDiff({ foo: { bar: true } }, { foo: {} })
Returns this as a result:
{
added: [ [ 'foo', {} ] ],
removed: [ [ 'foo/bar', true ] ],
edited: []
}
While I understand the removed
part, why would it consider foo
to be added?
Thanks!
{
"added": [
[
"0[]/",
""
]
],
"removed": [],
"edited": [
[
"0[]",
{},
"@{}"
]
]
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.