fix array mapper on complex values

This commit is contained in:
marhali 2022-02-07 19:21:44 +01:00
parent 0eb882e765
commit 512daedf09
2 changed files with 17 additions and 17 deletions

View File

@ -3,23 +3,25 @@
# easy-i18n Changelog
## [Unreleased]
### Fixed
- Exception on json array value mapping
## [3.0.0]
### BREAKING CHANGES
- The local file structure of your translation files must be configured in the settings menu
### BREAKING CHANGES
- The local file structure of your translation files must be configured in the settings menu
### Added
- Modularization supports namespace or locale module
- Full namespace / locale module support for all file types
- Support for object and array elements inside json arrays
- IDE integrated error report functionality
### Added
- Modularization supports namespace or locale module
- Full namespace / locale module support for all file types
- Support for object and array elements inside json arrays
- IDE integrated error report functionality
### Changed
- Improve exception handling on IO operations
- Update dependencies
### Changed
- Improve exception handling on IO operations
- Update dependencies
### Fixed
- Character unescaping for '.properties' files
### Fixed
- Character unescaping for '.properties' files
- Exception on json files without any content
## [2.0.0]

View File

@ -14,7 +14,7 @@ public class JsonArrayMapper extends ArrayMapper {
public static String read(JsonArray array) {
return read(array.iterator(), (jsonElement -> jsonElement.isJsonArray() || jsonElement.isJsonObject()
? jsonElement.toString()
? "\\" + jsonElement
: jsonElement.getAsString()));
}
@ -22,10 +22,8 @@ public class JsonArrayMapper extends ArrayMapper {
JsonArray array = new JsonArray();
write(concat, (element) -> {
if(element.startsWith("{") && element.endsWith("}")) {
array.add(GSON.fromJson(element, JsonObject.class));
} else if (element.startsWith("[") && element.endsWith("]")) {
array.add(GSON.fromJson(element, JsonArray.class));
if(element.startsWith("\\")) {
array.add(GSON.fromJson(element.replace("\\", ""), JsonElement.class));
} else {
array.add(element);
}