deepdiff icon indicating copy to clipboard operation
deepdiff copied to clipboard

malformed json output in diff cli?

Open rssh22 opened this issue 3 years ago • 3 comments

Please checkout the F.A.Q page before creating a bug ticket to make sure it is not already addressed.

Describe the bug The tool deep diff returns a malformed json output wich can't be processed by other tools like jq.

Example of malformed output:

{ 'values_changed': { "root['all']['children']['bus_r01_wls']['children']['bus_r01_wls_app']['children']['bus_r01_wls_app_des']['children']['bus_r01_wls_app_des_sns']['children']['wld_des_10']['hosts']['wls-des-10-sa-adm-n2']['lx_nm_port']": { 'new_value': '5112',
                                                                                                                                                                                                                                                    'old_value': '5110'}}}

To Reproduce deep diff k1.yaml k2.yaml

k1.yaml

algo: 
  algo_es_algo: falso

k2.yaml:

algo: 
  algo_es_algo: cierto
deep diff k1.yaml k2.yaml --ignore-order 
{ 'values_changed': { "root['algo']['algo_es_algo']": { 'new_value': 'falso',
                                                        'old_value': 'cierto'}}}

Expected behavior The output expected should be (in my humble opinion):

{
    "values_changed": {
        "root['all']['children']['bus_r01_wls']['children']['bus_r01_wls_app']['children']['bus_r01_wls_app_des']['children']['bus_r01_wls_app_des_sns']['children']['wld_des_10']['hosts']['wls-des-10-sa-adm-n2']['lx_nm_port']": {
            "new_value": "5112",
            "old_value": "5110"
        }
    }
}

OS, DeepDiff version and Python version (please complete the following information):

  • OS: Redhat
  • Version 7
  • DeepDiff; 5.7.0
  • Python 3.6.8

Additional context I'm using:

pip freeze
ansible==4.10.0
ansible-core==2.11.8
autopep8==1.6.0
bcrypt==3.2.0
cffi==1.15.0
chardet==4.0.0
clevercsv==0.7.1
click==8.0.3
cryptography==36.0.1
deepdiff==5.7.0
importlib-metadata==4.8.3
jeepney==0.7.1
Jinja2==3.0.3
keyring==23.4.1
keyrings.alt==4.1.0
MarkupSafe==2.0.1
ordered-set==4.0.2
packaging==21.3
paramiko==2.9.2
pycodestyle==2.8.0
pycparser==2.21
pycryptodome==3.14.1
pyinotify==0.9.6
PyNaCl==1.5.0
pyparsing==3.0.7
PyYAML==5.4.1
regex==2022.1.18
resolvelib==0.5.5
sagecipher==0.7.5
SecretStorage==3.3.1
six==1.16.0
toml==0.10.2
typing_extensions==4.1.1
zipp==3.6.0

rssh22 avatar Feb 18 '22 10:02 rssh22

Hi, It is not returning a json output. It is printing a python dictionary that is a superset of what json can hold.

Sep Dehpour

On Feb 18, 2022, at 2:38 AM, Raúl @.***> wrote:

 Please checkout the F.A.Q page before creating a bug ticket to make sure it is not already addressed.

Describe the bug The tool deep diff returns a malformed json output wich can't be processed by other tools like jq.

Example of malformed output:

{ 'values_changed': { "root['all']['children']['bus_r01_wls']['children']['bus_r01_wls_app']['children']['bus_r01_wls_app_des']['children']['bus_r01_wls_app_des_sns']['children']['wld_des_10']['hosts']['wls-des-10-sa-adm-n2']['lx_nm_port']": { 'new_value': '5112', 'old_value': '5110'}}} To Reproduce deep diff k1.yaml k2.yaml

k1.yaml

algo: algo_es_algo: falso k2.yaml:

algo: algo_es_algo: cierto deep diff k1.yaml k2.yaml --ignore-order { 'values_changed': { "root['algo']['algo_es_algo']": { 'new_value': 'falso', 'old_value': 'cierto'}}} Expected behavior The output expected should be (in my humble opinion):

{ "values_changed": { "root['all']['children']['bus_r01_wls']['children']['bus_r01_wls_app']['children']['bus_r01_wls_app_des']['children']['bus_r01_wls_app_des_sns']['children']['wld_des_10']['hosts']['wls-des-10-sa-adm-n2']['lx_nm_port']": { "new_value": "5112", "old_value": "5110" } } } OS, DeepDiff version and Python version (please complete the following information):

OS: [e.g. Ubuntu] Version [e.g. 20LTS] Additional context I'm using:

pip freeze ansible==4.10.0 ansible-core==2.11.8 autopep8==1.6.0 bcrypt==3.2.0 cffi==1.15.0 chardet==4.0.0 clevercsv==0.7.1 click==8.0.3 cryptography==36.0.1 deepdiff==5.7.0 importlib-metadata==4.8.3 jeepney==0.7.1 Jinja2==3.0.3 keyring==23.4.1 keyrings.alt==4.1.0 MarkupSafe==2.0.1 ordered-set==4.0.2 packaging==21.3 paramiko==2.9.2 pycodestyle==2.8.0 pycparser==2.21 pycryptodome==3.14.1 pyinotify==0.9.6 PyNaCl==1.5.0 pyparsing==3.0.7 PyYAML==5.4.1 regex==2022.1.18 resolvelib==0.5.5 sagecipher==0.7.5 SecretStorage==3.3.1 six==1.16.0 toml==0.10.2 typing_extensions==4.1.1 zipp==3.6.0 — Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you are subscribed to this thread.

seperman avatar Feb 18 '22 15:02 seperman

ou! Then, would you consider an enhancement request for a json output option?

rssh22 avatar Feb 21 '22 10:02 rssh22

Hi @rssh22 Sorry it took me a while to get back to you. Pull requests are always very welcome!

seperman avatar Apr 10 '22 00:04 seperman