Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pretty JSON generation #48

Open
QueerCodingGirl opened this issue Jan 26, 2016 · 10 comments
Open

Fix pretty JSON generation #48

QueerCodingGirl opened this issue Jan 26, 2016 · 10 comments

Comments

@QueerCodingGirl
Copy link

see: http://stackoverflow.com/questions/2567670/ruby-json-pretty-generate-is-pretty-unpretty
It would be really nice for reading and editing the backups before restoring them.

@pmoosh
Copy link
Collaborator

pmoosh commented Jan 29, 2016

Which version are you using and which data are you referring to?

@QueerCodingGirl
Copy link
Author

I am using version v0.0.11 and i am referring to the minified JSON, for example in the roles backup files.

@pmoosh
Copy link
Collaborator

pmoosh commented Jan 29, 2016

@DarkGigabyte - thx, by any chance did you look into other files that you backed up?
Will look into it.

@QueerCodingGirl
Copy link
Author

Yeah, i did. The data bags are fine and pretty formatted. The other categories are all not/unpretty formatted.

@pmoosh
Copy link
Collaborator

pmoosh commented Jan 29, 2016

@DarkGigabyte Send me an example if can. Mine look fine...

@QueerCodingGirl
Copy link
Author

Example of unpretty environment "development" exported on Linux Mint:
{"name":"development","description":"development","cookbook_versions":{"foobar_cookbook":"= 0.1.0"},"json_class":"Chef::Environment","chef_type":"environment","default_attributes":{},"override_attributes":{}}

How it should look pretty formatted:
http://pastebin.com/Ju7m7FUt

@glensc
Copy link

glensc commented Dec 21, 2018

it was prettified in 0.0.8, but something changed between 0.0.8-0.0.10

please add prettifying back, as i'm commiting the backup versions to git, it would be easier to see changes if prettified.

EDIT: i think the real change was with underlying ruby upgrade 1.9 -> 2.4

@glensc
Copy link

glensc commented Dec 21, 2018

i don't get it. if i read and invoke JSON.pretty_generate, it works fine:

file_name = 'nodes/example.json'
data = File.read(file_name)
some_data = JSON.parse(data)
encoded = JSON.pretty_generate(some_data)
yourfile = '/tmp/out.json'
File.open(yourfile, 'w') { |file| file.write(encoded) }

and the code uses same method: https://github.com/mdxp/knife-backup/blob/v0.0.12/lib/chef/knife/backup_export.rb#L127

@glensc
Copy link

glensc commented Dec 21, 2018

i'm even more puzzled, i updated 0.0.10 to 0.0.12 and the output is prettified.

versions (mostly note to myself):

$ rpm -q ruby knife-backup ruby-json
ruby-2.4.4-12.x86_64
knife-backup-0.0.12-1.noarch
ruby-json-2.0.4-2.4.4.12.x86_64

@glensc
Copy link

glensc commented Dec 22, 2018

so, imho it can be closed. as output is prettified

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants