Skip to content

Commit

Permalink
Add alias to json5 params of json
Browse files Browse the repository at this point in the history
  • Loading branch information
agentgt committed Jan 6, 2025
1 parent 5016d83 commit b9afdaf
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ public final class JSON5KeyValuesMedia implements KeyValuesMedia {
// @formatter:on
public static final String ARRAY_KEY_PARAM = "json5_arraykey";

private static final String ARRAY_KEY_ALIAS = "json_arraykey";

/**
* Will output array keys using array notation like <code>a[0]</code> instead of the
* default which is duplicating the keys.
Expand All @@ -162,6 +164,8 @@ public final class JSON5KeyValuesMedia implements KeyValuesMedia {
*/
public static final String SEPARATOR_PARAM = "json5_separator";

private static final String SEPARATOR_PARAM_ALIAS = "json_separator";

/**
* The default JSON path separator.
*/
Expand Down Expand Up @@ -193,6 +197,8 @@ public final class JSON5KeyValuesMedia implements KeyValuesMedia {
// @formatter:on
public static final String NUMBER_RAW_PARAM = "json5_number_raw";

private static final String NUMBER_RAW_ALIAS = "json_number_raw";

/**
* For service loader.
*/
Expand Down Expand Up @@ -224,17 +230,18 @@ public Parser parser(Variables parameters) {

enum Param implements Variables.Parameter {

ARRAY(ARRAY_KEY_PARAM), SEPARATOR(SEPARATOR_PARAM), NUMBER(NUMBER_RAW_PARAM);
ARRAY(ARRAY_KEY_PARAM, ARRAY_KEY_ALIAS), SEPARATOR(SEPARATOR_PARAM, SEPARATOR_PARAM_ALIAS),
NUMBER(NUMBER_RAW_PARAM, NUMBER_RAW_ALIAS);

private final String key;
private final List<String> keys;

private Param(String key) {
this.key = key;
private Param(String key, String alias) {
this.keys = List.of(key, alias);
}

@Override
public List<String> keys() {
return List.of(key);
return this.keys;
}

}
Expand Down

0 comments on commit b9afdaf

Please sign in to comment.