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


Java JsonArray.getString方法代码示例

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


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

示例1: read

import javax.json.JsonArray; //导入方法依赖的package包/类
public void read(JsonObject data) {
	this.data = data;
	
	type = data.getString("type", null);

	JsonArray jsonMacs = data.getJsonArray("macs");
	if (jsonMacs != null) {
		macs = new String[jsonMacs.size()];
		for (int i = 0; i < macs.length; ++i) {
			macs[i] = jsonMacs.getString(i);
		}
	}
	else {
		macs = new String[0];
	}
	
	throttled = data.getString("throttle", "true").equals("true");
	managed   = data.getString("managed", "false").equals("true");
}
 
开发者ID:privacyint,项目名称:thornsec-core,代码行数:20,代码来源:DeviceData.java

示例2: Group

import javax.json.JsonArray; //导入方法依赖的package包/类
/**
 * Create a group based on a JSON Object
 *
 * @param group The JSON Object with group information
 */
public Group(JsonObject group) {
  if (group.containsKey(JSON_KEY_GROUP_ID)) {
    id = group.getString(JSON_KEY_GROUP_ID);
  }
  name = group.getString(JSON_KEY_GROUP_NAME);

  JsonArray jsonMembers = group.getJsonArray(JSON_KEY_MEMBERS_LIST);
  if (jsonMembers != null) {
    members = new String[jsonMembers.size()];
    for (int i = 0; i < jsonMembers.size(); i++) {
      members[i] = jsonMembers.getString(i);
    }
  } else {
    members = new String[0];
  }
}
 
开发者ID:OpenLiberty,项目名称:sample-acmegifts,代码行数:22,代码来源:Group.java

示例3: getPropertyArray

import javax.json.JsonArray; //导入方法依赖的package包/类
public String[] getPropertyArray(String property) {
	JsonArray jsonProperties = data.getJsonArray(property);

	if (jsonProperties != null) {
		String[] properties = new String[jsonProperties.size()];
		for (int i = 0; i < properties.length; ++i) {
			properties[i] = jsonProperties.getString(i);
		}
		
		return properties;
	}
	else {
		return null;
	}
}
 
开发者ID:privacyint,项目名称:thornsec-core,代码行数:16,代码来源:ServerData.java

示例4: Group

import javax.json.JsonArray; //导入方法依赖的package包/类
public Group(String json) throws Exception {
  JsonObject jObject = stringToJsonObj(json);
  this.id = jObject.getString(JSON_KEY_GROUP_ID);
  this.name = jObject.getString(JSON_KEY_GROUP_NAME);

  JsonArray jsonMembers = jObject.getJsonArray(JSON_KEY_MEMBERS_LIST);
  if (jsonMembers != null) {
    members = new String[jsonMembers.size()];
    for (int i = 0; i < jsonMembers.size(); i++) {
      members[i] = jsonMembers.getString(i);
    }
  } else {
    members = new String[0];
  }
}
 
开发者ID:OpenLiberty,项目名称:sample-acmegifts,代码行数:16,代码来源:Group.java

示例5: getPropertyArray

import javax.json.JsonArray; //导入方法依赖的package包/类
private String[] getPropertyArray(String url, String name) throws Exception {
    JsonObject jo = JsonUtil.parseObject(getContent(url + "/" + name + ".json", CONTENT_TYPE_JSON));
    JsonArray arr = jo.getJsonArray(name);
    String[] result = new String[arr.size()];
    for (int i = 0; i < arr.size(); i++) {
        result[i] = arr.getString(i);
    }
    return result;
}
 
开发者ID:apache,项目名称:sling-org-apache-sling-launchpad-integration-tests,代码行数:10,代码来源:ReferenceTypeHintTest.java

示例6: read

import javax.json.JsonArray; //导入方法依赖的package包/类
public void read(JsonObject data) {
	this.data = data;
	
	adminUser = data.getString("user", null);
	JsonArray keys = data.getJsonArray("keys");
	if (keys != null) {
		adminKeys = new String[keys.size()];
		for (int i = 0; i < adminKeys.length; i++) {
			adminKeys[i] = keys.getString(i);
		}
	}
	JsonArray ips = data.getJsonArray("sshsource");
	if (ips != null) {
		adminIps = new String[ips.size()];
		for (int i = 0; i < adminIps.length; i++) {
			adminIps[i] = ips.getString(i);
		}
	}		
	adminFullName = data.getString("adminname", null);
	connection = data.getString("connection", "direct");
	subnet = data.getString("subnet", null);
	adminPort = data.getString("adminport", null);
	sshPort = data.getString("sshport", null);
	update = data.getString("update", null);
	hostname = data.getString("hostname", null);
	JsonArray jsonTypes = data.getJsonArray("types");
	if (jsonTypes != null) {
		types = new String[jsonTypes.size()];
		for (int i = 0; i < types.length; i++) {
			types[i] = jsonTypes.getString(i);
		}
	}
	iface = data.getString("iface", null);
	extIface = data.getString("extiface", null);
	metal = data.getString("metal", null);
	ram = data.getString("ram", null);
	diskSize = data.getString("disksize", null);
	dataDiskSize = data.getString("datadisksize", null);
	mac = data.getString("mac", null);
	cpus = data.getString("cpus", null);
	extConn = data.getString("extconnection", null);
	JsonArray jsonCnames = data.getJsonArray("cnames");
	if (jsonCnames != null) {
		cnames = new String[jsonCnames.size()];
		for (int i = 0; i < cnames.length; ++i) {
			cnames[i] = jsonCnames.getString(i);
		}
	}
	else {
		cnames = new String[0];
	}
	debianIsoUrl = data.getString("debianisourl", null);
	debianIsoSha512 = data.getString("debianisosha512", null);
	vmBase = data.getString("vmbase", null);
	JsonArray jsonProfiles = data.getJsonArray("profiles");
	if (jsonProfiles != null) {
		profiles = new String[jsonProfiles.size()];
		for (int i = 0; i < profiles.length; i++) {
			profiles[i] = jsonProfiles.getString(i);
		}
	}
	externalIp = data.getString("externalip", null);
	debianMirror = data.getString("debianmirror", null);
	debianDirectory = data.getString("debiandirectory", null);
	adminEmail = data.getString("adminemail", null);
	domain = data.getString("domain", null);
}
 
开发者ID:privacyint,项目名称:thornsec-core,代码行数:68,代码来源:ServerData.java

示例7: testWriteTo

import javax.json.JsonArray; //导入方法依赖的package包/类
/**
 * check dates
 * @throws IOException 
 */
@Test
public void testWriteTo() throws IOException {
    DecisionDaoProvider provider = new DecisionDaoProvider();
    InputStream in = new ByteArrayInputStream(MockData.MockExtraFieldsOne.getBytes(StandardCharsets.UTF_8));
        
    DecisionDao d = DecisionDaoProvider.readFrom(in);
    assertEquals(1,d.getSignerIds().size());
    
    final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    OutputStream out = new OutputStream() {
        @Override
        public void write(int b) throws IOException {
            buffer.write(b);
        }
    };
    
    DecisionDaoProvider.writeTo(d,out);
    
    byte[] arr = buffer.toByteArray();
    JsonReader jsonReader = Json.createReader(new StringReader(new String(arr,"utf-8")));
    JsonObject ob = jsonReader.readObject();
    
    assertNotNull(ob);
    
    assertEquals("ΑΠΟΦΑΣΗ ΑΝΑΛΗΨΗΣ ΥΠΟΧΡΕΩΣΗΣ",ob.getString("subject"));
    assertEquals("Β/100",ob.getString("protocolNumber"));
    
    assertEquals("30",ob.getString("organizationId"));
    assertEquals(1,ob.getJsonArray("signerIds").size());
    JsonArray signers = ob.getJsonArray("signerIds");
    String signerId = (String) signers.getString(0);
    assertEquals("10351",signerId);
    
    assertEquals(1,ob.getJsonArray("unitIds").size());
    JsonArray units = ob.getJsonArray("unitIds");
    String unitId = (String) units.getString(0);
    assertEquals("10480",unitId);
    
    JsonObject extra = ob.getJsonObject("extraFieldValues");
    assertNotNull(extra);
    
    assertEquals("Τακτικός Προϋπολογισμός",extra.getString("budgettype"));
    assertEquals(2014,extra.getInt("financialYear"));
    JsonObject amountWithVat = extra.getJsonObject("amountWithVAT");
    assertEquals(500,amountWithVat.getInt("amount"));
    assertEquals("EUR",amountWithVat.getString("currency"));
    
    JsonArray amountWithKae = extra.getJsonArray("amountWithKae");
    assertEquals(2,amountWithKae.size());
    
    JsonObject kae1 = (JsonObject) amountWithKae.get(0);
    assertEquals("1234",kae1.getString("kae"));
    assertEquals(200.231,kae1.getJsonNumber("amountWithVAT").doubleValue(),0.001);
    
    JsonObject kae2 = (JsonObject) amountWithKae.get(1);
    assertEquals("4321",kae2.getString("kae"));
    assertEquals(300,kae2.getInt("amountWithVAT"));
}
 
开发者ID:avraampiperidis,项目名称:DiavgeiaUtils,代码行数:63,代码来源:DecisionProviderTest.java


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