本文整理汇总了Java中com.bazaarvoice.jolt.JsonUtils.toJsonString方法的典型用法代码示例。如果您正苦于以下问题:Java JsonUtils.toJsonString方法的具体用法?Java JsonUtils.toJsonString怎么用?Java JsonUtils.toJsonString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.bazaarvoice.jolt.JsonUtils
的用法示例。
在下文中一共展示了JsonUtils.toJsonString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: map
import com.bazaarvoice.jolt.JsonUtils; //导入方法依赖的package包/类
public Collection<DynamicProperty> map(String source) {
//Default value is equal to the input json value (in case empty jolt specs)
String jsonProperties = source;
ArrayList transformed = (ArrayList) chainr.transform(JsonUtils.jsonToMap(source));
jsonProperties = JsonUtils.toJsonString(transformed);
//Now ensure current json properties is well formatted.
// if (validateJson(jsonProperties)) {
List<Object> items = JsonUtils.jsonToList(jsonProperties);
Object collect = items.stream()
.map(item -> {
Map<String, String> mapItem = (Map<String, String>) item;
Object key = mapItem.get("key");
if (key instanceof Number) {
return new DynamicProperty(key.toString(), mapItem.get("value"));
} else {
return new DynamicProperty((String) key, mapItem.get("value"));
}
})
.collect(Collectors.toList());
return (Collection<DynamicProperty>) collect;
}
示例2: migrate
import com.bazaarvoice.jolt.JsonUtils; //导入方法依赖的package包/类
public String migrate(String oldJSON, int targetVersion) {
LOGGER.debug("Migrating to version {}: {}", targetVersion, oldJSON);
Chainr transform = getTransformerFor(targetVersion);
Object transformedObject = transform.transform(JsonUtils.jsonToMap(oldJSON));
String transformedJSON = JsonUtils.toJsonString(transformedObject);
LOGGER.debug("After migration to version {}: {}", targetVersion, transformedJSON);
return transformedJSON;
}
示例3: versionOneComprehensiveWithNoLocking
import com.bazaarvoice.jolt.JsonUtils; //导入方法依赖的package包/类
public String versionOneComprehensiveWithNoLocking() {
Map<String, Object> map = getJSONFor("/v1_comprehensive.json");
store(map, "1", "target_version");
remove(map, "pipelines", 0, "enable_pipeline_locking");
remove(map, "pipelines", 1, "enable_pipeline_locking");
return JsonUtils.toJsonString(map);
}
示例4: versionOneWithLockingSetTo
import com.bazaarvoice.jolt.JsonUtils; //导入方法依赖的package包/类
public String versionOneWithLockingSetTo(boolean enablePipelineLockingValue) {
Map<String, Object> map = getJSONFor("/v1_simple.json");
store(map, "1", "target_version");
store(map, enablePipelineLockingValue, "pipelines", 0, "enable_pipeline_locking");
return JsonUtils.toJsonString(map);
}
示例5: versionTwoComprehensive
import com.bazaarvoice.jolt.JsonUtils; //导入方法依赖的package包/类
public String versionTwoComprehensive() {
return JsonUtils.toJsonString(getJSONFor("/v2_comprehensive.json"));
}