[IGN-4488]Is tags compare between 2 versions of the project impossible?

I have 2 versions of the project and i need to compare the tags to find out if there are missing tags/configuration in the master project. I have exported the tags (json file type) and when trying to compare the files using Notepad ++ i noticed that json re-shuffles the order of tags and comparison impossible which made me very sad :frowning:

Is there any other way to compare the tags to find what is missing in the master project?

General thought:
is using json file for exports not limiting ignition scada a lot as we cannot use excel for heavy duty manipulation of the tags?

Please help/advise

If you have a lot of tags you should do that with a program xd

Something like this? should output all the names that are not in the others list…

this should give you alteast some names to know where to look next xd

import json
def json_extract(obj, key):
	    """Recursively fetch values from nested JSON."""
	    arr = []
	
	    def extract(obj, arr, key):
	        """Recursively search for values of key in JSON tree."""
	        if isinstance(obj, dict):
	            for k, v in obj.items():
	                if isinstance(v, (dict, list)):
	                    extract(v, arr, key)
	                elif k == key:
	                    arr.append(v)
	        elif isinstance(obj, list):
	            for item in obj:
	                extract(item, arr, key)
	        return arr
	
	    values = extract(obj, arr, key)
	    return values


list1 = json_extract(json.loads(open('C:/Path/to/tags.json').read()), 'name')
list2 = json_extract(json.loads(open('C:/Path/to/tagsVersion2.json').read()), 'name')

compare = list(set(list1) - set(list2)) + list(set(list2) - set(list1))
print(compare)
1 Like

Use a tool that understands the semantics of JSON, e.g. http://www.jsondiff.com/
JSON is a human-readable format, but is not plain text.

On the contrary,

  1. Exporting to Excel would be dramatically limiting. Excel's strict row/column model, by definition, cannot fit nested data. If each row is a tag, where do you put properties that can have multiple values, such as alarms?
  2. Modern Excel versions can directly read JSON files, although you'll still ultimately have the same problem of shoving multi-dimensional nested data into a strict R/C format: Power Query JSON connector - Power Query | Microsoft Learn

Using a simple, but structured format, allows for a huge variety of tooling; JSON is a 'de-facto' standard for interchange between APIs and has an ecosystem to match. For instance, there's an incredibly powerful tool call jq that can make very complex operations absolutely trivial; see this post for an example:

1 Like

Ignition’s JSON output (everywhere) should still be sorted and repeatable for plain text diffs. For VCS compatibility, in addition to human eye-strain reduction. jsondiff and similar tools are a work-around, not a solution.

2 Likes

Views and other Perspective resources that land on disk are sorted, but that’s a good point, we should do that for other areas.

3 Likes

Where JSON compare tools like jsondiff fail though is where they don’t understand the tag structure built up of name keys and hence is unable to know that these are the keys and their props to compare with each other. A custom compare tool needs to be written which understands this inbuilt structure.

I wrote a tool in python, but it would be great if a compare tool would be added into ignition itself. I think there’s already an idea for it from memory

1 Like

While you are at it, let me plug the inclusion of defaults for properties. Yes, that makes files bigger. But it makes movement across versions more reliable (defaults can and have changed at times). Omitting them is a hangover from Vision resource optimization that shouldn’t be propagated.

2 Likes

Or make it an option to copy with defaults or without. Sometimes it’s useful not to have defaults, but for the majority of the time it would be better with, although maybe we’re talking about different things… I’m talking about copying json from the context menu

1 Like