[][src]Struct automaat_processor_json_edit::JsonEdit

pub struct JsonEdit {
    pub json: String,
    pub program: String,
    pub pretty_output: bool,
}

The processor configuration.

Fields

json: String

The JSON string that will be parsed by the program value.

program: String

The program to run against the provided json string.

A program can either filter the JSON down to a subset of data, or can mutate the data before returning a value.

To learn about the supported syntax, see the jq documentation:

https://stedolan.github.io/jq/manual/v1.6/

pretty_output: bool

"Pretty print" the JSON output.

If set to false, the JSON will be printed in a compact format, without any indentation, spacing or newlines.

Trait Implementations

impl Eq for JsonEdit[src]

impl PartialEq<JsonEdit> for JsonEdit[src]

impl Clone for JsonEdit[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for JsonEdit[src]

impl<'a> Processor<'a> for JsonEdit[src]

type Error = Error

If a processor fails its intended purpose, the returned error is turned into a string, and shown in the automaat-web-client application. Read more

type Output = String

The processor can return any (successful) output it wants, as long as that type implements the [std::fmt::Display] trait. Read more

fn validate(&self) -> Result<(), Self::Error>[src]

Validate that the provided program syntax is valid.

Errors

If the program contains invalid syntax, the Error::Json error variant is returned.

fn run(&self, _context: &Context) -> Result<Option<Self::Output>, Self::Error>[src]

Run the provided program against the json data.

Output

If the final output is a string, the surrounding JSON quotes are removed. This makes it easier to show raw strings in the UI, without having to use the regex processor to remove extra quotes.

This output:

"world"

Becomes this:

world

If pretty_output is set, any JSON object or array is pretty printed, by including newlines, indentation and spacing around the key/value pairs.

This output:

{"hello":"world"}

Becomes this:

{
  "hello": "world"
}

When unwrapping arrays in the program, each line is processed according to the above rules.

So this output:

[{"hello":"world"},"hello",2]

Becomes this:

{"hello":"world"}
hello
2

When using the program .[].

Errors

This method returns the Error::Json error variant if the provided json input or the program has invalid syntax.

The Error::Serde error variant is returned if the processor failed to serialize or deserialize the input/output JSON.

impl<'de> Deserialize<'de> for JsonEdit[src]

impl Serialize for JsonEdit[src]

Auto Trait Implementations

impl Send for JsonEdit

impl Sync for JsonEdit

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]