[FEATURE REQUEST] JSON parsing of cmd.run output. #67370
Replies: 7 comments
-
|
I'm not sure how useful it would be. If you're writing custom stuff that uses it, then you can just parse the string yourself (as above). If you're on the CLI you can e.g.: |
Beta Was this translation helpful? Give feedback.
-
|
One way to look at this is bringing parity between Custom code that uses the Salt API requires an awkward two phase process of first decoding it as a string, and then as JSON. |
Beta Was this translation helpful? Give feedback.
-
|
Custom code has easy access to a JSON parser. Most Piping through |
Beta Was this translation helpful? Give feedback.
-
|
I agree with @OrangeDog this isn't the job of cmd.run. in fact something like this adds a layer of complexity and a fail point to what is one of the more robust functions. |
Beta Was this translation helpful? Give feedback.
-
|
It would be useful to construct variables in templates. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
|
Thank you, @whytewolf - that's very useful. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Many commands, such as
lldpcli, can emit output in JSON and other formats. Currentlycmd.runand its relatives return the output as a string, but it would be nice if the decoding could be done by Salt before the output is returned. It is much easier to visually parse well structured output than it is a wall of text.This would be very similar to what is provided by
salt.pillar.cmd_json, except for ad-hoc command execution.A trivial implementation:
Beta Was this translation helpful? Give feedback.
All reactions