-
Notifications
You must be signed in to change notification settings - Fork 11
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 option(s) to force PPrint to print inline jsons for same layout without considering its length? #58
Comments
My short answerNo, I will not add additional config options for the How you can do this with current JsonTools v7.1This may not work if you have JSON with comments or JSON that is otherwise noncompliant, because the
My longer answerI don't want to add lots of complicated bespoke pretty-printing config options, but I am willing to add a new pretty-printing method that uses a RemesPath query to determine whether to compress or pretty-print JSON. I might call this method I believe that this is a reasonably low-maintenance (for me) and powerful (for users) way to define arbitrary pretty-printing rules. My hypothetical query-based For example, here's some JSON where most of the elements are tagged with the parameters for each call to the {
"employees": [
{
"id": 213, // json = 213; path = ["employees", 0, "id"]; indent = " "
"name": "franc", // json = "franc"; path = ["employees", 0, "name"]; indent = " "
"another": [
[
{ // json = {"abc": "test"}; path = ["employees", 0, "another", 0, 0]; indent = " "
"abc": "test" // json = "test"; path = ["employees", 0, "another", 0, 0, "abc"]; indent = " "
},
{ // json = {"foo": "bar"}; path = ["employees", 0, "another", 0, 1]; indent = " "
"foo": "bar" // json = "bar"; path = ["employees", 0, "another", 0, 1, "foo"]; indent = " "
}
]
]
},
{
"id": [ // json = ["blah"]; path = ["employees", 1, "id"]; indent = " "
"blah" // json = "blah"; path = ["employees", 1, "id", 0]; indent = " "
]
}
]
}
A callback function (in pseudocode) that would work the same as the current
Another callback (again in pseudocode) that would work the same as the current
|
JmesPath sounds promising. In this case, maybe we can choose some commonly used variables to make custom expression as callback, anytime when PPrint (or RemesPrint), eval this expression to determine whether to perform compression or not, this way, users don't have to actually write code. (like expressions in Excel)。 |
I am closing this issue, and have no intention of implementing any feature that I previously mentioned considering. See #61 for a relevant tutorial. |
Hi there,
This is pretty:
With longer
xyz
, it becomes this (which is not what i wanted)With even longer
xyz
:With above longest example, what i expected:
Can this be done by adding options to ignore value length for same layout when PPrint? or maybe add options to PPrint by indent levels?
Thank you, for the great tool.
The text was updated successfully, but these errors were encountered: