JsonConverter extends AbstractConfigurationConverter { JsonValue readJsonObjectFromValue(final String key, final @Nullable Object value) throws ComponentConfigurationException { if (value instanceof JsonObject) { return (JsonObject) value; } else if (value instanceof String) { try (JsonReader reader = Json.createReader(new StringReader((String) value))) { return reader.readObject(); } catch (JsonException e) { throw new ComponentConfigurationException("Failed to parse value for key " + key + " as JsonObject.", 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);  }
@Test public void testReadJsonObjectFromValue() throws Exception { final JsonObject expectSameObject = key("foo", "one").key("bar", "two").get(); assertSame("same json object", expectSameObject, converter().readJsonObjectFromValue("key", expectSameObject)); assertSame("null value is JsonValue.NULL", JsonValue.NULL, converter().readJsonObjectFromValue("key", null)); assertEquals("json object as string is equal", expectSameObject, converter().readJsonObjectFromValue("key", expectSameObject.toString())); }
@Test(expected = ComponentConfigurationException.class) public void testReadJsonObjectFromValue_throws() throws Exception { converter().readJsonObjectFromValue("key", "some string"); }