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


Java JsonWriter.objectToJson方法代码示例

本文整理汇总了Java中com.cedarsoftware.util.io.JsonWriter.objectToJson方法的典型用法代码示例。如果您正苦于以下问题:Java JsonWriter.objectToJson方法的具体用法?Java JsonWriter.objectToJson怎么用?Java JsonWriter.objectToJson使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.cedarsoftware.util.io.JsonWriter的用法示例。


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

示例1: encryptObject

import com.cedarsoftware.util.io.JsonWriter; //导入方法依赖的package包/类
@Override
public EncryptedMessage encryptObject(Object o) 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");
	}
	
	
	try {
		String json = JsonWriter.objectToJson(o);
		
		EncryptedMessage msg = new EncryptedMessage();
		
		Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
		cipher.init(Cipher.ENCRYPT_MODE, key);
		msg.setMsg(cipher.doFinal(json.getBytes("UTF-8")));
		msg.setIv(cipher.getIV());
		return msg;
	} catch (IOException | NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | IllegalBlockSizeException | BadPaddingException e) {
		throw new ProvisioningException("Could not encrypt message",e);
	}
	
}
 
开发者ID:TremoloSecurity,项目名称:OpenUnison,代码行数:24,代码来源:ProvisioningEngineImpl.java

示例2: save

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

    if (!file.exists()) {
        file.createNewFile();
    } else {
        file.delete();
    }

    // Generating pretty json
    Map<String, Object> args = new HashMap<>();
    args.put("JsonWriter.PRETTY_PRINT", true);
    String json = JsonWriter.objectToJson(player.getAttributes(), args);
    json = JsonWriter.formatJson(json);

    // Writing json
    FileWriter writer = new FileWriter(file);
    writer.write(json);
    writer.close();
}
 
开发者ID:PureCS,项目名称:runesource,代码行数:23,代码来源:JsonPlayerFileHandler.java

示例3: testFlags

import com.cedarsoftware.util.io.JsonWriter; //导入方法依赖的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

示例4: saveData

import com.cedarsoftware.util.io.JsonWriter; //导入方法依赖的package包/类
/**
 * Adatok mentése lemezre.
 */
private void saveData() {
    System.out.println("SaveData");
    
    String dataString = null;
    try {
        dataString = JsonWriter.objectToJson(playerData);
    } catch (IOException e1) {
        e1.printStackTrace();
    }
    
    if (dataString != null) {
        Preferences prefs = Preferences.userRoot().node(this.getClass().getName());
        prefs.put("data", dataString);
    }
}
 
开发者ID:tiborsimon,项目名称:java-shooter-game,代码行数:19,代码来源:DataManager.java

示例5: AzRule

import com.cedarsoftware.util.io.JsonWriter; //导入方法依赖的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

示例6: testSchemaSerialized

import com.cedarsoftware.util.io.JsonWriter; //导入方法依赖的package包/类
@Test
public void testSchemaSerialized() throws Throwable {
    Schema main = SchemaBuilder.record("Main").fields().name("C").type().stringType().noDefault().name("D").type()
            .stringType().noDefault().endRecord();

    Property schemaMain = PropertyFactory.newSchema("main");
    schemaMain.setValue(main);

    String jsonMain = JsonWriter.objectToJson(schemaMain);
    System.out.println(jsonMain);
}
 
开发者ID:Talend,项目名称:daikon,代码行数:12,代码来源:SchemaTest.java

示例7: format

import com.cedarsoftware.util.io.JsonWriter; //导入方法依赖的package包/类
/**
 * Translates response object to JSON representation
 * @param prettyPrint pretty print JSON or not
 * @param o response object
 * @return response as JSON String
 */
public String format(boolean prettyPrint, Object o) {
    args.clear();
    args.put(JsonWriter.PRETTY_PRINT, prettyPrint);
    args.put(JsonWriter.DATE_FORMAT, "dd/MMM/yyyy:kk:mm:ss Z");
    args.put(JsonWriter.TYPE, false);
    return JsonWriter.objectToJson(o, args)+"\r\n";
}
 
开发者ID:gskorupa,项目名称:Cricket,代码行数:14,代码来源:JsonFormatter.java

示例8: getConfigAsString

import com.cedarsoftware.util.io.JsonWriter; //导入方法依赖的package包/类
public String getConfigAsString(ConfigSet c) {
    Map nameBlackList = new HashMap();
    ArrayList blackList = new ArrayList();
    blackList.add("host");
    blackList.add("port");
    blackList.add("threads");
    blackList.add("filter");
    blackList.add("cors");
    nameBlackList.put(Configuration.class, blackList);
    Map args = new HashMap();
    args.put(JsonWriter.PRETTY_PRINT, true);
    //args.put(JsonWriter., args)
    return JsonWriter.objectToJson(c, args);
}
 
开发者ID:gskorupa,项目名称:Cricket,代码行数:15,代码来源:Runner.java

示例9: save

import com.cedarsoftware.util.io.JsonWriter; //导入方法依赖的package包/类
public FlowLog save(String flowId, String flowChanId, String key, Payload payload, Map<Object, Object> variables, Class<?> flowType,
        FlowState currentState) {
    String payloadJson = JsonWriter.objectToJson(payload, writeOptions);
    String variablesJson = JsonWriter.objectToJson(variables, writeOptions);
    FlowLog flowLog = new FlowLog(payload.getStackId(), flowId, flowChanId, key, payloadJson, payload.getClass(), variablesJson, flowType,
            currentState.toString());
    flowLog.setCloudbreakNodeId(cloudbreakNodeConfig.getId());
    return flowLogRepository.save(flowLog);
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:10,代码来源:FlowLogService.java

示例10: export

import com.cedarsoftware.util.io.JsonWriter; //导入方法依赖的package包/类
/**
 * Játékos adatainak exportálása.
 */
public void export() {
    System.out.println("DataManager: export");
    String filename = showFileChooser("Export");
    
    String dataString = null;
    try {
        dataString = JsonWriter.objectToJson(playerData);
    } catch (IOException e1) {
        e1.printStackTrace();
    }
    
    if (dataString != null) {
        try {
            FileUtils.writeStringToFile(new File(filename), dataString);
            System.out.println("File exported :)");
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
        
    /*
    // Save the object to file
    FileOutputStream fos = null;
    ObjectOutputStream out = null;
    try {
        fos = new FileOutputStream(filename);
        out = new ObjectOutputStream(fos);
        out.writeObject(playerData);

        out.close();
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    */
}
 
开发者ID:tiborsimon,项目名称:java-shooter-game,代码行数:40,代码来源:DataManager.java

示例11: marshal

import com.cedarsoftware.util.io.JsonWriter; //导入方法依赖的package包/类
@Override
public String marshal ( Object o ) throws Exception {
    return JsonWriter.objectToJson(o);
}
 
开发者ID:mbechler,项目名称:marshalsec,代码行数:5,代码来源:JsonIO.java

示例12: spitJson

import com.cedarsoftware.util.io.JsonWriter; //导入方法依赖的package包/类
private void spitJson(PrintStream out, Object graphElement) {
  String json = JsonWriter.objectToJson(graphElement);
  out.print(json);
}
 
开发者ID:spideruci,项目名称:cerebro-layout,代码行数:5,代码来源:DynamicFlowGraph.java

示例13: serialize

import com.cedarsoftware.util.io.JsonWriter; //导入方法依赖的package包/类
public static String serialize(Object o) throws IOException{
	if(o == null){
		return null;
	}
	return JsonWriter.objectToJson(o);
}
 
开发者ID:BenoitRonflette,项目名称:FreeYourCode,代码行数:7,代码来源:JsonSerialisationUtils.java

示例14: enqueue

import com.cedarsoftware.util.io.JsonWriter; //导入方法依赖的package包/类
public void enqueue(WorkflowHolder wfHolder) throws ProvisioningException {
	
	
	TextMessage bm;
	try {
		
		
		
		MessageProducer mp;
		MessageProducerHolder mph = null;
		
		if (this.isInternalQueue()) {
			mp = this.taskMP;
			bm = taskSession.createTextMessage();
			bm.setStringProperty("OriginalQueue", this.taskQueue.getQueueName());
		} else {
			mph = this.getTaskMessageProducer();
			mp = mph.getProducer();
			bm = mph.getSession().createTextMessage();
			bm.setStringProperty("OriginalQueue", ((javax.jms.Queue) mph.getProducer().getDestination()).getQueueName());
		}
		
		bm.setStringProperty("WorkflowName", wfHolder.getWorkflow().getName());
		bm.setStringProperty("WorkflowSubject", wfHolder.getUser().getUserID());
		
		TaskHolder holder = wfHolder.getWfStack().peek();
		WorkflowTask task = holder.getParent().get(holder.getPosition());
	
		
		bm.setStringProperty("WorkflowCurrentTask", task.getLabel());
		
		EncryptedMessage encMsg = this.encryptObject(wfHolder);
		
		String json = JsonWriter.objectToJson(encMsg);
		bm.setText(json);
		
		
		try {
			mp.send(bm);
		} finally {
			if (! this.isInternalQueue()) {
				this.returnMessageProducer(mph);
			}
		}
	} catch (Exception e) {
		throw new ProvisioningException("Could not enqueue message",e);
	}
	
}
 
开发者ID:TremoloSecurity,项目名称:OpenUnison,代码行数:50,代码来源:ProvisioningEngineImpl.java

示例15: toString

import com.cedarsoftware.util.io.JsonWriter; //导入方法依赖的package包/类
public String toString() {
    return JsonWriter.objectToJson(this);
}
 
开发者ID:enableiot,项目名称:iotanalytics-backend,代码行数:4,代码来源:ComponentSearchRequest.java


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