pub fn match_json(expected: &Vec<u8>, actual: &Vec<u8>, config: DiffConfig,
    mismatches: &mut Vec<super::Mismatch>, matchers: &MatchingRules) {
    let expected_json = serde_json::from_slice(expected);
    let actual_json = serde_json::from_slice(actual);

    if expected_json.is_err() || actual_json.is_err() {
        match expected_json {
            Err(e) => {
                mismatches.push(Mismatch::BodyMismatch { path: s!("$"), expected: Some(expected.clone().into()),
                    actual: Some(actual.clone().into()),
                    mismatch: format!("Failed to parse the expected body: '{}'", e)});
            },
            _ => ()
        }
        match actual_json {
            Err(e) => {
                mismatches.push(Mismatch::BodyMismatch { path: s!("$"), expected: Some(expected.clone().into()),
                    actual: Some(actual.clone().into()),
                    mismatch: format!("Failed to parse the actual body: '{}'", e)});
            },
            _ => ()
        }
    } else {
        compare(&vec![s!("$")], &expected_json.unwrap(), &actual_json.unwrap(), &config,
            mismatches, matchers);
    }
}
/// Matches the expected JSON to the actual, and populates the mismatches vector with any differences
Matches the expected JSON to the actual, and populates the mismatches vector with any differences
Matches the expected JSON to the actual and populates the mismatches vector with any differences
pub fn match_json(expected: &Vec<u8>, actual: &Vec<u8>, config: DiffConfig,
    mismatches: &mut Vec<super::Mismatch>, matchers: &MatchingRules) {
    let expected_json = serde_json::from_slice(expected);
    let actual_json = serde_json::from_slice(actual);
    if expected_json.is_err() || actual_json.is_err() {
        match expected_json {
            Err(e) => {
                mismatches.push(Mismatch::BodyMismatch { path: s!("$"), expected: Some(expected.clone().into()),
                    actual: Some(actual.clone().into()),
                    mismatch: format!("Failed to parse the expected body: '{}'", e)});
            },
            _ => ()
        }
        match actual_json {
            Err(e) => {
                mismatches.push(Mismatch::BodyMismatch { path: s!("$"), expected: Some(expected.clone().into()),
                    actual: Some(actual.clone().into()),
                    mismatch: format!("Failed to parse the actual body: '{}'", e)});
            },
            _ => ()
        }
    } else {
        compare(&vec![s!("$")], &expected_json.unwrap(), &actual_json.unwrap(), &config,
            mismatches, matchers);
    }
}
pub fn match_json ( expected : & Vec < u8 > , actual : & Vec < u8 > , config : DiffConfig , mismatches : & mut Vec < super :: Mismatch > , matchers : & MatchingRules ) { let expected_json = serde_json :: from_slice ( expected ) ; let actual_json = serde_json :: from_slice ( actual ) ; if expected_json . is_err ( ) || actual_json . is_err ( ) { match expected_json { Err ( e ) => { mismatches . push ( Mismatch :: BodyMismatch { path : s ! ( " " ) , expected : Some ( expected . clone ( ) . into ( ) ) , actual : Some ( actual . clone ( ) . into ( ) ) , mismatch : format ! ( " " e ) } ) ; } , _ => ( ) } match actual_json { Err ( e ) => { mismatches . push ( Mismatch :: BodyMismatch { path : s ! ( " " ) , expected : Some ( expected . clone ( ) . into ( ) ) , actual : Some ( actual . clone ( ) . into ( ) ) , mismatch : format ! ( " " e ) } ) ; } , _ => ( ) } } else { compare ( & vec ! [ s ( " " ) ] , & expected_json . unwrap ( ) , & actual_json . unwrap ( ) , & config , mismatches , matchers ) ; } }
Matches the expected JSON to the actual, and populates the mismatches vector with any differences
Matches the expected JSON to the actual and populates the mismatches vector with any differences
expected
&Vec<u8>
actual
&Vec<u8>
config
DiffConfig
mismatches
&mut Vec<super::Mismatch>
matchers
&MatchingRules
expected
&Vec<u8>
actual
&Vec<u8>
config
DiffConfig
mismatches
&mut Vec<super::Mismatch>
matchers
&MatchingRules