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

Add pretty printing capability #13

Closed
wants to merge 4 commits into from

Conversation

stokesman
Copy link

@stokesman stokesman commented Nov 20, 2022

These changes add the ability to pretty print the results of json2php and a unit test for such use cases.

Here's one place interest in this feature has been expressed: WordPress/wordpress-develop#2252 (comment)

If you'd be open to merging this I'd be glad to update the docs as part of the PR.

Quick example:

const printer = json2php.make({linebreak:'\n', indent:'\t'})
printer({one: 3, two: 20, three: [9, 3, 2]})

/* result:
array(
	'one' => 3, 
	'two' => 20, 
	'set' => array(
		9, 
		3, 
		2
	)
)
*/

@daniel-zahariev
Copy link
Owner

Hi, @stokesman, this looks great!
I'll be able to review tomorrow and very likely merge.

@stokesman
Copy link
Author

Thanks @daniel-zahariev! I just pushed 9442df4 to make it a little prettier.

@daniel-zahariev
Copy link
Owner

@stokesman, thank you for your contribution 🙏🏻
I had to do some clean up and was time constrained so went the easy route and did the changes in the code myself.
Please, forgive me for that. I've added you to the list of contributors.

@stokesman
Copy link
Author

All good, thanks for adding the feature!

@stokesman stokesman deleted the add/pretty-print branch November 22, 2022 15:58
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

Successfully merging this pull request may close these issues.

2 participants