GitHub
github.com › 5SSS › vue-json-compare
GitHub - 5SSS/vue-json-compare: vue(2.x) json compare components,live demo:https://codesandbox.io/s/suspicious-elion-bwl6v?file=/src/App.vue
import vueJsonCompare from 'vue-json-compare'; const oldData = { name: 'super', age: 18, task: [ { name: 'eat', time: '09:00' }, { name: 'work', time: '10:00', deleted: 'this prop has been deleted!' }, { name: 'sleep', time: '22:00' }, ], }; const newData = { name: 'coolapt', age: 20, task: [ { name: 'eat', time: '09:00' }, { name: 'work', time: '10:00' }, { name: 'sleep', time: '23:00' }, { name: 'running', time: '08:00' }, ], }; export default { components: { vueJsonCompare, }, data() { return { oldData: oldData, newData: newData, }; }, };
Starred by 45 users
Forked by 11 users
Languages Vue 58.7% | JavaScript 41.3% | Vue 58.7% | JavaScript 41.3%
npm
npmjs.com › package › vue-json-compare
vue-json-compare - npm
August 20, 2020 - A vue(2.x) components for compare JSON data. Latest version: 3.0.0, last published: 5 years ago. Start using vue-json-compare in your project by running `npm i vue-json-compare`. There are 3 other projects in the npm registry using vue-json-compare.
» npm install vue-json-compare
Published Aug 20, 2020
Version 3.0.0
Author alpaca
CodeSandbox
codesandbox.io › examples › package › vue-json-compare
vue-json-compare examples - CodeSandbox
Use this online vue-json-compare playground to view and fork vue-json-compare example apps and templates on CodeSandbox.
npm
npmjs.com › package › json-diff-kit
json-diff-kit - npm
November 23, 2025 - import { Differ } from 'json-diff-kit'; // or if you are using vue, you can import the differ only import Differ from 'json-diff-kit/dist/differ'; // the two JS objects const before = { a: 1, b: 2, d: [1, 5, 4], e: ['1', 2, { f: 3, g: null, h: [5], i: [] }, 9], m: [], q: 'JSON diff can\'t be possible', r: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', s: 1024, }; const after = { b: 2, c: 3, d: [1, 3, 4, 6], e: ['1', 2, 3, { f: 4, g: false, i: [7, 8] }, 10], j: { k: 11, l: 12 }, m: [ { n: 1, o: 2 }, { p: 3 }, ], q:
» npm install json-diff-kit
Published Mar 03, 2026
Version 1.0.35
Author Rex Zeng
Repository https://github.com/RexSkz/json-diff-kit
GitHub
github.com › qinxm › vue-json-diff
GitHub - qinxm/vue-json-diff: A vue json diff component that based on feHelper.
<template> <div id="app"> <json-diff :jsonSourceLeft="leftData" :jsonSourceRight="rightData" /> </div> </template> <script> import JsonDiff from 'vue-json-diff' export default { components: { JsonDiff }, data() { return { leftData: { "data": { "needQueryPosition": 0, "orderStatus": "已取消", "orderTrace": { "timeLine": [ { "date": "10/13", "time": "18:26", "status": "订单已取消" }, { "date": "10/13", "time": "18:11", "status": "订单提交成功" } ], "lastStatusDesc": "订单未支付,已自动取消" } }, "code": 0, "msg": "", "success": true }, rightData: { "data": { "needQueryPo
Starred by 27 users
Forked by 10 users
Languages CSS 40.9% | Vue 29.6% | JavaScript 29.5% | CSS 40.9% | Vue 29.6% | JavaScript 29.5%
Vue.js Examples
vuejsexamples.com › a-vue-components-for-compare-json-data
A vue components for compare JSON data
March 1, 2019 - <template> <div> <vue-json-compare :oldData="oldData" :newData="newData"></vue-json-compare> </div> </template> import vueJsonCompare from 'vue-json-compare' export default { components: { vueJsonCompare }, data () { return { oldData: { a: 1, e: 0 }, newData: { a: 2 b: 3 } } } } Json ·
Top answer 1 of 2
2
First off create a method that will return appropriate icon. I believe the code of getIconClass method is self-explanatory. Then loop through leafs field in template and display name of the leaf and appropriate icon.
new Vue({
el: "#app",
data() {
return {
generalQuestInfo: [{
"id": 1,
"name": "Breaking News",
"alias": "BN",
"globalId": 1,
"platform": "Win64",
"pathway": {
"status": "Robot",
"name": "start case",
"leafs": ["start", "teleport", "take photo", "kill", "finish"]
}
}],
finishedQuestleafs: [
{ name: "start", questId: 2 },
{ name: "teleport", questId: 1 },
{ name: "take photo", questId: 1 },
{ name: "kill", questId: 1 },
{ name: "finish", questId: 1 },
{ name: "start", questId: 2 }
]
}
},
methods: {
getIconClass(id, leaf) {
return this.finishedQuestleafs.find(item => item.questId === id && item.name === leaf) ? "fa fa-check" : "fa fa-bomb";
}
}
})
.as-console-wrapper { max-height: 100% !important; top: 0; }
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
<table align="center">
<tr>
<th>Status</th>
<th>Path name</th>
<th>Leafs Info</th>
</tr>
<tr v-for="data in generalQuestInfo" :key="data.id">
<td>{{data.pathway.status}}</td>
<td>{{data.pathway.name}}</td>
<td>
<ul>
<li v-for="(leaf, index) in data.pathway.leafs" :key="index">
<i :class="getIconClass(data.id, leaf)"></i> {{ leaf }}
</li>
</ul>
</td>
</tr>
</table>
</div>
2 of 2
1
You could try making a method to check while you're in the v-for loop.
<tr v-for="data in generalQuestInfo">
<span v-if="hasQuestFinished(data.id, data.pathway.leafs)">
<!-- display stuff if hasQuestFinished() returned true -->
</span>
</tr>
And in your vue object (assuming you only want to check if its in the array:
methods:{
hasQuestFinished(questID, givenQuests){
finishedQuestleafs.forEach(function(leaf){
if(leaf.questId == questID && givenQuests.indexOF(leaf.name) >= 0){
return true;
}
});
//finished the loop without returning means no match
return false;
}
}
npm
npmjs.com › package › @types › vue-json-compare
@types/vue-json-compare - npm
November 7, 2023 - import Vue from "vue"; type JsonObject = Record<string, any> | Array<Record<string, any>>; declare class VueJsonCompare extends Vue { oldData: JsonObject; newData: JsonObject; } export default VueJsonCompare;
» npm install @types/vue-json-compare
Published Nov 07, 2023
Version 3.0.4
Top answer 1 of 4
1
Since the listing is an array and not an object you need to loop over it with index:
function checkOccurence(data, listing) {
let dataFound = false;
for(let i = 0; i < listing.length; i++) {
if (listing[i].pid === data.pid) {
dataFound = true;
break;
}
}
return dataFound;
};
Then you can use the returned boolean in your render to determine success or failure like this:
<div if="checkOccurence(data, listing)"> Success </div> <div v-else>Failure</div>
2 of 4
1
define exists method in your methods ,
methods: {
exists: function() {
var exist = false;
var listings = self.listings;
var data = self.data;
for(var listing of listings) {
if (listing.pid == data.pid) {
exist = true;
break;
}
}
return exist;
}
}
And you should call the method like this,
<div if="exists()"> Success </div> <div v-else> Failure</div>
CodeSandbox
codesandbox.io › examples › package › vue-json-diff
vue-json-diff examples - CodeSandbox
Vuetify Pagination with Data Fetching (forked) justgowthams1629 · AboutA json diff vue component88Weekly Downloads · Latest version1.0.1 · LicenseISC · External Links · github.com/qinxm/vue-json-diff#readme · github.com/qinxm/vue-json-diff/issues ·
npm
npmjs.com › package › vue-json-diff
vue-json-diff - npm
October 22, 2020 - <template> <div id="app"> <json-diff :jsonSourceLeft="leftData" :jsonSourceRight="rightData" /> </div> </template> <script> import JsonDiff from 'vue-json-diff' export default { components: { JsonDiff }, data() { return { leftData: { "data": { "needQueryPosition": 0, "orderStatus": "已取消", "orderTrace": { "timeLine": [ { "date": "10/13", "time": "18:26", "status": "订单已取消" }, { "date": "10/13", "time": "18:11", "status": "订单提交成功" } ], "lastStatusDesc": "订单未支付,已自动取消" } }, "code": 0, "msg": "", "success": true }, rightData: { "data": { "needQueryPo
» npm install vue-json-diff
GitHub
github.com › RexSkz › json-diff-kit-vue
GitHub - RexSkz/json-diff-kit-vue: The Vue version of Viewer used by json-diff-kit. (Beta) · GitHub
<script setup lang="ts"> import { Differ, Viewer } from '@json-diff-kit/viewer-vue'; import type { DifferOptions, ViewerProps } from '@json-diff-kit/viewer-vue'; const differProps: DifferOptions = { detectCircular: false, maxDepth: Infinity, showModifications: true, arrayDiffMethod: 'lcs', ignoreCase: false, recursiveEqual: true, preserveKeyOrder: true, }; const differ = new Differ(differProps); const before = { a: 1, b: 2, c: 3 }; const after = { a: 1, b: 3, d: 4 }; const diff = differ.diff(before, after); const viewerProps: Partial<ViewerProps> = { diff, indent: 2, lineNumbers: true, highlig
Starred by 2 users
Forked by 2 users
Languages Vue 55.6% | TypeScript 43.1% | HTML 1.3%
Codespots
codespots.com › library › item › 1017
A vue components for compare JSON data - Codespots.com
February 26, 2023 - <template> <div> <vue-json-compare :oldData="oldData" :newData="newData"></vue-json-compare> </div> </template> import vueJsonCompare from 'vue-json-compare' export default { components: { vueJsonCompare }, data () { return { oldData: { a: 1, e: 0 }, newData: { a: 2 b: 3 } } } } not yet...
Npm
npm.io › package › vue-json-compare
Vue-json-compare NPM | npm.io
import vueJsonCompare from 'vue-json-compare' export default { components: { vueJsonCompare }, data () { return { oldData: { a: 1, e: 0 }, newData: { a: 2 b: 3 } } } }