-
-
Notifications
You must be signed in to change notification settings - Fork 38
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
Output in the same order as defined #52
Comments
I tried submitting the PR only to later realize that there are no guarantees over the order of the keys in the use serde_json::Value;
fn main() {
let data = r#"
{
"name": "John Doe",
"age": 43,
"phones": [
"+44 1234567",
"+44 2345678"
]
}"#;
// Parse the string of data into serde_json::Value.
let v: Value = serde_json::from_str(data).unwrap();
let s: String = serde_json::to_string(&v).unwrap();
println!("{}", s)
} I'll elaborate on a better design for kct. Sorry for even bothering you with this question. I'm still discovering Rust and remembering practices from college days when I worked directly with data structures. If you happen to have any idea, I'll be more than pleased to hear it and learn from you. |
By jsonnet spec - fields in manifest should be ordered by alphanumeric Also, json itself doesn't guarantee field order, per RFC 7159
So you shouldn't rely on fields order :D For kubernetes manifest purpose you should probally implement toposort for applying some objects before dependents (I.e |
Released this feature as experimental in https://github.com/CertainLach/jrsonnet/releases/tag/v0.5.0-pre1-test |
Is there any practical reason, or laid out by the spec, on why the fields get ordered when manifesting?
I plan on using the order of the fields to determine how
kct
applies resources to the cluster. But as the fields get ordered during manifestation, I'm a bit lost and can't find an alternative on what else to use. Honestly, setting my interests with kct aside, I find it a little strange to have the rendered fields in a different order than what I defined in my templates.I checked that the official implementation does the same, and it seems that you aim to have similar output. I hope it isn't too much of a stretch to ask for this, but can we leave the order of the fields as defined in the templates?
The text was updated successfully, but these errors were encountered: