当前位置: 首页>>代码示例>>Java>>正文


Java JsonReader类代码示例

本文整理汇总了Java中com.cedarsoftware.util.io.JsonReader的典型用法代码示例。如果您正苦于以下问题:Java JsonReader类的具体用法?Java JsonReader怎么用?Java JsonReader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JsonReader类属于com.cedarsoftware.util.io包,在下文中一共展示了JsonReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: UsersJsonProvider

import com.cedarsoftware.util.io.JsonReader; //导入依赖的package包/类
public UsersJsonProvider() {
    jacksonAfterburner.registerModule(new AfterburnerModule());

    jsonioStreamOptions.put(JsonReader.USE_MAPS, true);
    jsonioStreamOptions.put(JsonWriter.TYPE, false);

    // set johnson JsonReader (default is `JsonProvider.provider()`)
    javax.json.spi.JsonProvider johnzonProvider = new JsonProviderImpl();
    johnzon = new org.apache.johnzon.mapper.MapperBuilder()
        .setReaderFactory(johnzonProvider.createReaderFactory(Collections.emptyMap()))
        .setGeneratorFactory(johnzonProvider.createGeneratorFactory(Collections.emptyMap()))
        .setAccessModeName("field") // default is "strict-method" which doesn't work nicely with public attributes
        .build();

    PreciseFloatSupport.enable();
}
 
开发者ID:fabienrenaud,项目名称:java-json-benchmark,代码行数:17,代码来源:UsersJsonProvider.java

示例2: testFlags

import com.cedarsoftware.util.io.JsonReader; //导入依赖的package包/类
@Test
public void testFlags() {
    Property<String> element = newProperty("element");
    assertFalse(element.isFlag(Property.Flags.ENCRYPT));
    assertFalse(element.isFlag(Property.Flags.HIDDEN));
    element.addFlag(Property.Flags.ENCRYPT);
    assertTrue(element.isFlag(Property.Flags.ENCRYPT));
    assertFalse(element.isFlag(Property.Flags.HIDDEN));
    element.addFlag(Property.Flags.HIDDEN);
    assertTrue(element.isFlag(Property.Flags.ENCRYPT));
    assertTrue(element.isFlag(Property.Flags.HIDDEN));
    element.removeFlag(Property.Flags.HIDDEN);
    assertTrue(element.isFlag(Property.Flags.ENCRYPT));
    assertFalse(element.isFlag(Property.Flags.HIDDEN));
    element.removeFlag(Property.Flags.ENCRYPT);
    assertFalse(element.isFlag(Property.Flags.ENCRYPT));
    assertFalse(element.isFlag(Property.Flags.HIDDEN));

    String elementStr = JsonWriter.objectToJson(element);
    element = (Property) JsonReader.jsonToJava(elementStr);
    element.addFlag(Property.Flags.HIDDEN);

    element.addFlag(Property.Flags.ENCRYPT);
    assertTrue(element.isFlag(Property.Flags.ENCRYPT));

}
 
开发者ID:Talend,项目名称:daikon,代码行数:27,代码来源:PropertyTest.java

示例3: decryptObject

import com.cedarsoftware.util.io.JsonReader; //导入依赖的package包/类
@Override
public Object decryptObject(EncryptedMessage msg) throws ProvisioningException {
	SecretKey key = this.cfgMgr.getSecretKey(this.cfgMgr.getCfg().getProvisioning().getQueueConfig().getEncryptionKeyName());
	if (key == null) {
		throw new ProvisioningException("Queue message encryption key not found");
	}
	
	IvParameterSpec spec =  new IvParameterSpec(msg.getIv());
    Cipher cipher;
	try {
		cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
		cipher.init(Cipher.DECRYPT_MODE, key,spec);
		
		
		byte[] bytes = cipher.doFinal(msg.getMsg());
		
		return JsonReader.jsonToJava(new String(bytes));
	} catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | InvalidAlgorithmParameterException | IllegalBlockSizeException | BadPaddingException  e) {
		throw new ProvisioningException("Could not decrypt message",e);
	}
	
}
 
开发者ID:TremoloSecurity,项目名称:OpenUnison,代码行数:23,代码来源:ProvisioningEngineImpl.java

示例4: AzRule

import com.cedarsoftware.util.io.JsonReader; //导入依赖的package包/类
public AzRule(String scopeType,String constraint, String className,ConfigManager cfgMgr,Workflow wf) throws ProvisioningException {
	if (scopeType.equalsIgnoreCase("group")) {
		scope = ScopeType.Group;
	} else if (scopeType.equalsIgnoreCase("dynamicGroup")) {
		scope = ScopeType.DynamicGroup;
	} else if (scopeType.equalsIgnoreCase("dn")) {
		scope = ScopeType.DN;
	} else if (scopeType.equalsIgnoreCase("custom")) {
	 	scope = ScopeType.Custom;
	 	
		CustomAuthorization caz = cfgMgr.getCustomAuthorizations().get(constraint);
		
		if (caz == null) {
			logger.warn("Could not find custom authorization rule : '" + className + "'");
		}
		
		String json = JsonWriter.objectToJson(caz);
		this.customAz = (CustomAuthorization) JsonReader.jsonToJava(json);
		try {
			this.customAz.setWorkflow(wf);
		} catch (AzException e) {
			throw new ProvisioningException("Can not set workflow",e);
		}
	} else if (scopeType.equalsIgnoreCase("filter")) {
		scope = ScopeType.Filter;
	}
	
	this.constraint = constraint;
	this.guid = UUID.randomUUID();
	this.className = className;
	
	while (usedGUIDS.contains(guid)) {
		this.guid = UUID.randomUUID();
	}
	
	
	

	
}
 
开发者ID:TremoloSecurity,项目名称:OpenUnison,代码行数:41,代码来源:AzRule.java

示例5: read

import com.cedarsoftware.util.io.JsonReader; //导入依赖的package包/类
@Override
public Object read(Object jOb, Deque<JsonObject<String, Object>> stack, Map<String, Object> args) {
    ObjectResolver resolver = (ObjectResolver) args.get(JsonReader.OBJECT_RESOLVER);
    JsonObject<String, Object> jsonObject = (JsonObject<String, Object>) jOb;
    Object versionObj = jsonObject.get(VERSION_FIELD);
    long version = 0;
    if (versionObj != null) {
        version = ((Long) versionObj).longValue();
    }
    resolver.traverseFields(stack, (JsonObject<String, Object>) jOb);
    Object target = ((JsonObject<String, Object>) jOb).getTarget();
    if (target instanceof PostDeserializeHandler) {
        postDeserializeHandlers.put((PostDeserializeHandler) target, (int) version);
    }
    return target;
}
 
开发者ID:Talend,项目名称:daikon,代码行数:17,代码来源:SerializerDeserializer.java

示例6: load

import com.cedarsoftware.util.io.JsonReader; //导入依赖的package包/类
@Override
public LoadResponse load(Player player) throws Exception {
    // Checking if file exists
    File file = new File(getStorageDirectory() + player.getAttributes().getUsername() + ".json");

    if (!file.exists()) {
        return LoadResponse.NOT_FOUND;
    }

    // Reading file
    JsonReader reader = new JsonReader(new FileInputStream(file));
    PlayerAttributes attributes = (PlayerAttributes) reader.readObject();
    reader.close();

    // Checking password
    if (!attributes.getPassword().equals(player.getAttributes().getPassword())) {
        return LoadResponse.INVALID_CREDENTIALS;
    }
    player.setAttributes(attributes);
    return LoadResponse.SUCCESS;
}
 
开发者ID:PureCS,项目名称:runesource,代码行数:22,代码来源:JsonPlayerFileHandler.java

示例7: handleResponse

import com.cedarsoftware.util.io.JsonReader; //导入依赖的package包/类
private void handleResponse(String jsonResponseString) throws IOException {
    if (jsonResponseString == null || jsonResponseString.trim().isEmpty()) {
        throw new IOException(getMessage("error.emptyResponse"));
    }
    try {
        // JSONParser jsonParser = new JSONParser();
        JsonObject<Object, Object> json = (JsonObject<Object, Object>) JsonReader.jsonToJava(jsonResponseString);
        LOGGER.debug("Response String:/r/n" + String.valueOf(json));
        lastErrorCode = ((Long) json.get("code")).intValue();
        lastErrorMessage = (String) json.get("text");
        if (lastErrorCode != 0) {
            throw new IOException(getMessage("error.codeMessage", lastErrorCode, lastErrorMessage));
        }
        successCount += splunkObjectsForBulk.size();
    } catch (JsonIoException e) {
        throw new IOException(getMessage("error.responseParseException", e.getMessage()));
    }
}
 
开发者ID:Talend,项目名称:components,代码行数:19,代码来源:TSplunkEventCollectorWriter.java

示例8: restartFlow

import com.cedarsoftware.util.io.JsonReader; //导入依赖的package包/类
public void restartFlow(String flowId) {
    FlowLog flowLog = flowLogRepository.findFirstByFlowIdOrderByCreatedDesc(flowId);
    if (RESTARTABLE_FLOWS.contains(flowLog.getFlowType())) {
        Optional<FlowConfiguration<?>> flowConfig = flowConfigs.stream()
                .filter(fc -> fc.getClass().equals(flowLog.getFlowType())).findFirst();
        Payload payload = (Payload) JsonReader.jsonToJava(flowLog.getPayload());
        Flow flow = flowConfig.get().createFlow(flowId, payload.getStackId());
        runningFlows.put(flow, flowLog.getFlowChainId());
        if (flowLog.getFlowChainId() != null) {
            flowChainHandler.restoreFlowChain(flowLog.getFlowChainId());
        }
        Map<Object, Object> variables = (Map<Object, Object>) JsonReader.jsonToJava(flowLog.getVariables());
        flow.initialize(flowLog.getCurrentState(), variables);
        RestartAction restartAction = flowConfig.get().getRestartAction(flowLog.getNextEvent());
        if (restartAction != null) {
            restartAction.restart(flowId, flowLog.getFlowChainId(), flowLog.getNextEvent(), payload);
            return;
        }
    }
    flowLogService.terminate(flowLog.getStackId(), flowId);
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:22,代码来源:Flow2Handler.java

示例9: setupJsonReader

import com.cedarsoftware.util.io.JsonReader; //导入依赖的package包/类
@PostConstruct
public void setupJsonReader() {
    JsonReader.assignInstantiator("com.google.common.collect.RegularImmutableBiMap", new MapFactory());
    JsonReader.assignInstantiator("com.google.common.collect.RegularImmutableMap", new MapFactory());
    JsonReader.assignInstantiator("com.google.common.collect.EmptyImmutableBiMap", new MapFactory());
    JsonReader.assignInstantiator("com.google.common.collect.SingletonImmutableBiMap", new MapFactory());
    JsonReader.assignInstantiator("java.util.Collections$EmptyMap", new MapFactory());
    JsonReader.assignInstantiator("java.util.Collections$SingletonMap", new MapFactory());

    JsonReader.assignInstantiator("com.google.common.collect.SingletonImmutableList", new CollectionFactory());
    JsonReader.assignInstantiator("com.google.common.collect.RegularImmutableList", new CollectionFactory());
    JsonReader.assignInstantiator("java.util.Collections$EmptyList", new CollectionFactory());
    JsonReader.assignInstantiator("java.util.Collections$SingletonList", new CollectionFactory());

    JsonReader.assignInstantiator("com.google.common.collect.RegularImmutableSet", new CollectionFactory());
    JsonReader.assignInstantiator("java.util.Collections$EmptySet", new CollectionFactory());
    JsonReader.assignInstantiator("java.util.Collections$SingletonSet", new CollectionFactory());
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:19,代码来源:JsonIoConfig.java

示例10: loadData

import com.cedarsoftware.util.io.JsonReader; //导入依赖的package包/类
/**
 * Adatok olvasása lemezről.
 */
private void loadData() {
    System.out.println("LoadData");
    
    Preferences prefs = Preferences.userRoot().node(this.getClass().getName());
    String loadedString = prefs.get("data", null);
    
    if (loadedString != null) {
        try {
            playerData = (PlayerData) JsonReader.jsonToJava(loadedString);
            System.out.println("File loaded :)");
        } catch (IOException e1) {
            e1.printStackTrace();
            System.exit(-1);
        }
    } else {
        playerData = null;
    }
}
 
开发者ID:tiborsimon,项目名称:java-shooter-game,代码行数:22,代码来源:DataManager.java

示例11: deserialize

import com.cedarsoftware.util.io.JsonReader; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static <T> T deserialize(String serialized) throws IOException{
	if(serialized == null){
		return null;
	}
	return (T) JsonReader.jsonToJava(serialized);
}
 
开发者ID:BenoitRonflette,项目名称:FreeYourCode,代码行数:8,代码来源:JsonSerialisationUtils.java

示例12: getJsonMap

import com.cedarsoftware.util.io.JsonReader; //导入依赖的package包/类
/**
 * Returns the supplied Json file as a String key Object value map
 * @throws IOException 
 * @throws FileNotFoundException 
 */

public static Map<String, Object> getJsonMap(String propertiesFile) throws FileNotFoundException, IOException {
	String jsonProperties = IOUtils.toString(new FileInputStream(new File(propertiesFile)));
	Map<String, Object> properties = JsonReader.jsonToMaps(jsonProperties);
	return properties;
}
 
开发者ID:NEO-IE,项目名称:numbertron,代码行数:12,代码来源:JsonUtils.java

示例13: fromSerialized

import com.cedarsoftware.util.io.JsonReader; //导入依赖的package包/类
/**
 * Returns a materialized object from a previously serialized JSON String.
 *
 * @param serialized created by {@link #toSerialized(Object object, boolean persistent)}.
 * @param serializedClass the class of the object being deserialized
 * @param persistent see {@link #PERSISTENT} and {@link #TRANSIENT}.
 * @return a {@code Properties} object represented by the {@code serialized} value.
 */
public static <T> Deserialized<T> fromSerialized(InputStream serialized, Class<T> serializedClass, PostDeserializeSetup setup,
        boolean persistent) {

    // serializedClass is not used, but we have it only for the generic type support so the caller
    // can avoid casting.
    Deserialized<T> d = new Deserialized<T>();

    Map<PostDeserializeHandler, Integer> postDeserializeHandlers = new HashMap<>();

    Map<Class, JsonReader.JsonClassReaderEx> readerMap = new HashMap<>();
    readerMap.put(DeserializeMarker.class, new CustomReader(postDeserializeHandlers));

    final AtomicBoolean migratedDeleted = new AtomicBoolean(false);// we need to pass the ref.

    Map<String, Object> args = new HashMap<>();
    args.put(JsonReader.CUSTOM_READER_MAP, readerMap);
    args.put(JsonReader.MISSING_FIELD_HANDLER, new MissingFieldHandler(migratedDeleted));
    // in case the json has not type we can try to instantiate the expected type.
    if (serializedClass != null) {
        args.put(JsonReader.UNKNOWN_OBJECT, serializedClass.getCanonicalName());
    }

    d.object = (T) JsonReader.jsonToJava(serialized, args);
    boolean migrated = false;
    for (Entry<PostDeserializeHandler, Integer> entry : postDeserializeHandlers.entrySet()) {
        // use Entry key because the hash code may have changed
        migrated |= entry.getKey().postDeserialize(entry.getValue(), setup, persistent);
    }
    d.migrated = migrated || migratedDeleted.get();
    return d;
}
 
开发者ID:Talend,项目名称:daikon,代码行数:40,代码来源:SerializerDeserializer.java

示例14: loadWeaponDefinitions

import com.cedarsoftware.util.io.JsonReader; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static void loadWeaponDefinitions(String fileName) throws FileNotFoundException {
    // Checking if file exists
    File file = new File(fileName);

    if (!file.exists()) {
        throw new FileNotFoundException("The weapon definitions file was not found");
    }

    // Reading file
    JsonReader reader = new JsonReader(new FileInputStream(file));
    WEAPONS = ((ArrayList<WeaponDefinition>) reader.readObject()).toArray(new WeaponDefinition[0]);
    reader.close();
}
 
开发者ID:PureCS,项目名称:runesource,代码行数:15,代码来源:EquipmentHelper.java

示例15: load

import com.cedarsoftware.util.io.JsonReader; //导入依赖的package包/类
public static Settings load(String fileName) throws Exception {
    // Checking if file exists
    File file = new File(fileName);

    if (!file.exists()) {
        throw new FileNotFoundException("The settings file was not found");
    }

    // Reading file
    JsonReader reader = new JsonReader(new FileInputStream(file));
    Settings settings = (Settings) reader.readObject();
    reader.close();
    return settings;
}
 
开发者ID:PureCS,项目名称:runesource,代码行数:15,代码来源:Settings.java


注:本文中的com.cedarsoftware.util.io.JsonReader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。