Java 类org.springframework.boot.json.JsonParserFactory 实例源码

项目:fish-admin    文件:Role.java   
/**
 * 验证是否有访问权限
 * @param entity entity名称
 * @param access 访问权限: read, create, update, destroy
 * @return
 */
public boolean hasPermission(Object entity, Object access) {
    if (Strings.isNullOrEmpty(permissions)) return false;
    Map ps = JsonParserFactory.getJsonParser().parseMap(permissions);

    String entityName;
    if (entity instanceof String) {
        entityName = (String) entity;
    } else {
        entityName = (String) entity;
    }

    String permission;
    if (access instanceof Permission) {
        permission = ((Permission) access).name();
    } else {
        permission = (String) access;
    }

    if (ps.containsKey(entityName)) {
        List<String> methodNames = (List<String>) ps.get(entityName);
        return methodNames.stream().filter(m -> m.equals(permission)).count() > 0;
    }
    return false;
}
项目:OpenViSu    文件:Json2MapReader.java   
public Json2MapReader(String json)
{
  JsonParser parser = JsonParserFactory.getJsonParser();
  map = parser.parseMap(json);
  // For creating test files:
  // try {
  // FileWriter writer = new FileWriter(new SimpleDateFormat("yyyy-MM-dd_HH_mm_ss.SSS").format(new Date()) + "-json.txt");
  // writer.append(json);
  // writer.close();
  // } catch (IOException e) {
  // System.out.println(e.getMessage());
  // }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SpringApplicationJsonEnvironmentPostProcessor.java   
private void processJson(ConfigurableEnvironment environment, String json) {
    try {
        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);
    }
}
项目:spring-cloud-stream-binder-google-pubsub    文件:PubSubServiceAutoConfiguration.java   
@Bean
@Profile("cloud")
public PubSub pubSubCloud(Environment environment) throws Exception {
    String vcapServicesEnv = environment.getProperty("VCAP_SERVICES");
    JsonParser parser = JsonParserFactory.getJsonParser();
    Map<String, Object> services = parser.parseMap(vcapServicesEnv);
    List<Map<String, Object>> googlePubsub = (List<Map<String, Object>>) services.get("google-pubsub");
    Map<String, Object> credentials = (Map<String, Object>) googlePubsub.get(0).get("credentials");
    String privateKeyData = (String) credentials.get("PrivateKeyData");
    GoogleCredential googleCredential = GoogleCredential.fromStream(new ByteArrayInputStream(Base64.decodeBase64(privateKeyData)));

    return PubSubOptions.newBuilder().setAuthCredentials(AuthCredentials.createFor(googleCredential.getServiceAccountId(),
            googleCredential.getServiceAccountPrivateKey()))
            .setProjectId(pubSubBinderConfigurationProperties.getProjectName()).build().getService();
}
项目:spring-boot-concourse    文件:SpringApplicationJsonEnvironmentPostProcessor.java   
private void processJson(ConfigurableEnvironment environment, String json) {
    try {
        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);
    }
}
项目:fish-admin    文件:Role.java   
@JsonIgnore
public Map getPermissionsMap() {
    return Strings.isNullOrEmpty(permissions) ?
            new HashMap() : JsonParserFactory.getJsonParser().parseMap(permissions);
}
项目:static-creds-broker    文件:PlanProperties.java   
public void setCredentialsJson(String credentialsJson) {
    JsonParser parser = JsonParserFactory.getJsonParser();
    this.credentialsJson = parser.parseMap(credentialsJson);
}
项目:static-creds-broker    文件:ServiceProperties.java   
public void setCredentialsJson(String credentialsJson) {
    JsonParser parser = JsonParserFactory.getJsonParser();
    this.credentialsJson = parser.parseMap(credentialsJson);
}
项目:cf-cassandra-spring-example-app    文件:CloudCassandraPropertiesManager.java   
private Map<String, Object> getJsonMapFromEnvironment() {
    JsonParser jsonParser = JsonParserFactory.getJsonParser();
    Map<String, Object> jsonMap;
    jsonMap = jsonParser.parseMap(getVCapVariable());
    return (Map<String, Object>) ((List<Map<String, Object>>) jsonMap.get( "p-cassandra")).get(0).get("credentials");
}