Example usage for org.springframework.boot.json JsonParser parseMap

List of usage examples for org.springframework.boot.json JsonParser parseMap

Introduction

In this page you can find the example usage for org.springframework.boot.json JsonParser parseMap.

Prototype

Map<String, Object> parseMap(String json) throws JsonParseException;

Source Link

Document

Parse the specified JSON string into a Map.

Usage

From source file:org.springframework.boot.env.SpringApplicationJsonEnvironmentPostProcessor.java

private void processJson(ConfigurableEnvironment environment, String json) {
    try {// w  ww .j a v  a 2s . co  m
        JsonParser parser = JsonParserFactory.getJsonParser();
        Map<String, Object> map = parser.parseMap(json);
        if (!map.isEmpty()) {
            addJsonPropertySource(environment, new MapPropertySource("spring.application.json", flatten(map)));
        }
    } catch (Exception ex) {
        logger.warn("Cannot parse JSON for spring.application.json: " + json, ex);
    }
}