@Test public void testReadJsonValueFromValue() throws Exception { assertSame("null value is JsonValue.NULL", JsonValue.NULL, converter().readJsonValueFromValue("key", null)); assertSame("same json null value", JsonValue.NULL, converter().readJsonValueFromValue("key", JsonValue.NULL)); assertSame("same json empty object", JsonValue.EMPTY_JSON_OBJECT, converter().readJsonValueFromValue("key", JsonValue.EMPTY_JSON_OBJECT)); assertSame("same json empty array", JsonValue.EMPTY_JSON_ARRAY, converter().readJsonValueFromValue("key", JsonValue.EMPTY_JSON_ARRAY)); assertEquals("\"some string\" is readable", JavaxJson.wrap("some string"), converter().readJsonValueFromValue("key", "\"some string\"")); }
JsonValue readJsonValueFromValue(final String key, final @Nullable Object value) throws ComponentConfigurationException { if (value instanceof JsonValue) { return (JsonValue) value; } else if (value instanceof String) { try (JsonReader reader = Json.createReader(new StringReader((String) value))) { return reader.readValue(); } catch (JsonException e) { throw new ComponentConfigurationException("Failed to parse value for key " + key + " as JsonValue.", e); } } return JsonObject.NULL; }
JsonConverter extends AbstractConfigurationConverter { JsonValue readJsonValueFromValue(final String key, final @Nullable Object value) throws ComponentConfigurationException { if (value instanceof JsonValue) { return (JsonValue) value; } else if (value instanceof String) { try (JsonReader reader = Json.createReader(new StringReader((String) value))) { return reader.readValue(); } catch (JsonException e) { throw new ComponentConfigurationException("Failed to parse value for key " + key + " as JsonValue.", e); } } return JsonObject.NULL; } }
JsonConverter extends AbstractConfigurationConverter { JsonValue readJsonValueFromValue(final String key, final @Nullable Object value) throws ComponentConfigurationException { if (value instanceof JsonValue) { return (JsonValue) value; } else if (value instanceof String) { try (JsonReader reader = Json.createReader(new StringReader((String) value))) { return reader.readValue(); } catch (JsonException e) { throw new ComponentConfigurationException("Failed to parse value for key " + key + " as JsonValue.", e); } } return JsonObject.NULL; }  }
JsonConverter extends AbstractConfigurationConverter { JsonValue readJsonValueFromValue(final String key, final @Nullable Object value) throws ComponentConfigurationException { if (value instanceof JsonValue) { return (JsonValue) value; } else if (value instanceof String) { try (JsonReader reader = Json.createReader(new StringReader((String) value))) { return reader.readValue(); } catch (JsonException e) { throw new ComponentConfigurationException("Failed to parse value for key " + key + " as JsonValue.", e); } } return JsonObject.NULL; }  static String plexusPluralStem(final String key); @Override boolean canConvert(final Class<?> type); @Override Object fromConfiguration(final ConverterLookup lookup,
                                    final PlexusConfiguration configuration,
                                    final Class<?> type,
                                    final Class<?> enclosingType,
                                    final ClassLoader loader,
                                    final ExpressionEvaluator evaluator,
                                    final ConfigurationListener listener); JsonValue convertChild(final @NotNull PlexusConfiguration child, final ExpressionEvaluator evaluator); static Object stringToValue(String string); }
JsonConverter extends AbstractConfigurationConverter { JsonValue readJsonValueFromValue(final String key, final @Nullable Object value) throws ComponentConfigurationException { if (value instanceof JsonValue) { return (JsonValue) value; } else if (value instanceof String) { try (JsonReader reader = Json.createReader(new StringReader((String) value))) { return reader.readValue(); } catch (JsonException e) { throw new ComponentConfigurationException("Failed to parse value for key " + key + " as JsonValue.", e); } } return JsonObject.NULL; }  static String plexusPluralStem(final String key); @Override boolean canConvert(final Class<?> type); @Override Object fromConfiguration(final ConverterLookup lookup,
                                    final PlexusConfiguration configuration,
                                    final Class<?> type,
                                    final Class<?> enclosingType,
                                    final ClassLoader loader,
                                    final ExpressionEvaluator evaluator,
                                    final ConfigurationListener listener); JsonValue convertChild(final @NotNull PlexusConfiguration child, final ExpressionEvaluator evaluator); static Object stringToValue(String string);  }