AlecTroemel / quickxml_to_serde

Convert between XML JSON using quickxml and serde
MIT License
24 stars 14 forks source link

Enforce array for some XML nodes #14

Closed rimutaka closed 3 years ago

rimutaka commented 3 years ago

Closes #13

Changes

  1. Bumped the version to 0.4.3
  2. Updated ReadMe with examples and explanations
  3. Added built-in tests

Breaking changes

Specifying the JSON type is a 2-level enum.

It used to be just JsonType::AlwaysString. Now the type has to be wrapped into JsonArray like this: JsonArray::Infer(JsonType::AlwaysString))

Before:

let conf = Config::new_with_defaults()
        .add_json_type_override("/a/@attr1", JsonType::AlwaysString)
        .add_json_type_override("/a/b/@attr1", JsonType::AlwaysString)
        .add_json_type_override("/a/b", JsonType::AlwaysString);

After:

    let conf = Config::new_with_defaults()
        .add_json_type_override("/a/@attr1", JsonArray::Infer(JsonType::AlwaysString))
        .add_json_type_override("/a/b/@attr1", JsonArray::Infer(JsonType::AlwaysString))
        .add_json_type_override("/a/b", JsonArray::Infer(JsonType::AlwaysString));

It's not a big change. I fixed the existing code with a single global search and replace.

Testing

Apart from the built-in tests it has been running in PROD for a couple of weeks.

@AlecTroemel , Alec, please, take a look if you have a minute.

AlecTroemel commented 3 years ago

LGTM!