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


Java JSON.encode方法代码示例

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


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

示例1: send

import net.arnx.jsonic.JSON; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 * <pre>
 * jsonを送信します。
 * </pre>
 */
@Override
public void send(final HttpServletResponse resp) throws Exception {
	resp.setContentType(this.getContentType());
	Object obj = this;
	PrintWriter out = resp.getWriter();
	try {
		if (obj != null) {
			String json = JSON.encode(obj, DataFormsServlet.isJsonDebug());
			if (log.isDebugEnabled()) {
				log.debug("json=" + json);
			}
			out.print(json);
		}
	} finally {
		out.flush();
		out.close();
	}
}
 
开发者ID:takayanagi2087,项目名称:dataforms,代码行数:25,代码来源:JsonResponse.java

示例2: getJson

import net.arnx.jsonic.JSON; //导入方法依赖的package包/类
@Execute(validator = false)
public String getJson() {
   	
   	List<TParty> tPartyList = tPartyService.findAllForCalender();
   	List<FullCalenderDto> calList = new ArrayList<FullCalenderDto>();
   	if (tPartyList.size() > 0) {
   		for (TParty tParty : tPartyList) {
   			calList.add(new FullCalenderDto(tParty));
   		}
   	}
   	
   	String json = JSON.encode(calList);
   	
   	ResponseUtil.write(json, "application/json");
   	
       return null;
}
 
开发者ID:kagucho,项目名称:tsubonesystem2,代码行数:18,代码来源:FulCalenderApiAction.java

示例3: onReadText

import net.arnx.jsonic.JSON; //导入方法依赖的package包/类
@Override
public void onReadText(final WebSocketContext context,
        final String key, final String message) throws IOException {
    final Map<String, Object> m = JSON.decode(message);
    final Object ping = m.get("ping");
    final Object messageId = m.get("messageId");
    if (messageId != null) {
        if (ping != null) {
            final Optional<String> latestId = IMBoxMessageIdManager.messageId(key);
            if (latestId.isPresent()) {
                final Map<String, Object> id = new HashMap<>();
                id.put("messageId", latestId.get());
                id.put("pong", ping);
                final String pong = JSON.encode(id);
                synchronized (context) {
                    final PrintWriter out = context.startTextMessage();
                    out.print(pong); // initialize browser's memo
                    out.close();
                }
            }
        } else { // set the latest messageId at first time
            final String mid = messageId instanceof String ? (String) messageId : "";
            IMBoxMessageIdManager.messageId(key, Optional.of(mid));
        }
    }
}
 
开发者ID:Global-Solutions,项目名称:web_notifications_imbox_plugin,代码行数:27,代码来源:IMBoxTakerImpl.java

示例4: subQueryTest

import net.arnx.jsonic.JSON; //导入方法依赖的package包/类
/**
 * 各種問い合わせのテストメソッド。
 * @throws Exception 例外。
 */
public void subQueryTest() throws Exception {
	TestQuery query = new TestQuery();
	List<Map<String, Object>> list = this.executeQuery(query);
	String json = JSON.encode(list, true);
	log.debug("testQueryResult=" + json);
}
 
开发者ID:takayanagi2087,项目名称:dataforms,代码行数:11,代码来源:AllTypeDao.java

示例5: encryptDownloadParameter

import net.arnx.jsonic.JSON; //导入方法依赖的package包/类
/**
 * 暗号化されたダウンロードパラメータを取得します。
 * @param p ダウンロードパラメータマップ。
 * @return 暗号化されたダウンロードパラメータ。
 */
public String encryptDownloadParameter(final Map<String, Object> p) {
	String json = JSON.encode(p, false);
	String ret = "";
	try {
		ret = java.net.URLEncoder.encode(CryptUtil.encrypt(json, DataFormsServlet.getQueryStringCryptPassword()), DataFormsServlet.getEncoding());
	} catch (Exception e) {
		e.printStackTrace();
	}
	return ret;
}
 
开发者ID:takayanagi2087,项目名称:dataforms,代码行数:16,代码来源:FileStore.java

示例6: getDBValue

import net.arnx.jsonic.JSON; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 * <pre>
 * DBに保存する場合json形式に変換します。
 * </pre>
 */
@Override
public Object getDBValue() {
	String ret = null;
	if (!StringUtil.isBlank(this.getValue())) {
		ret = JSON.encode(this.getValue(), true);
	}
	return ret;
}
 
开发者ID:takayanagi2087,项目名称:dataforms,代码行数:15,代码来源:MultiSelectField.java

示例7: sendMail

import net.arnx.jsonic.JSON; //导入方法依赖的package包/类
/**
	 * 確認メール送信。
	 * 
	 * @param data 登録データ。
	 * @throws Exception 例外。
	 */
	protected void sendMail(final Map<String, Object> data) throws Exception {
		String path = this.getAppropriatePath("/mailTemplate/userRegistMail.txt", this.getPage().getRequest());
		String text = this.getWebResource(path);
		log.debug("mailTemplate=" + text);
		MailTemplate template = new MailTemplate(text, null);
		UserInfoTable.Entity e = new UserInfoTable.Entity(data);
		template.addToAddress(e.getMailAddress());
		template.setFrom(MailSender.getMailFrom());
		template.setReplyTo(MailSender.getMailFrom());
		template.setArg(UserInfoTable.Entity.ID_USER_NAME, e.getUserName());
		
		HttpServletRequest req = this.getPage().getRequest();
		String url = req.getRequestURL().toString();
		String uri = req.getRequestURI();
		url = url.replaceAll(uri, req.getContextPath()) + UserRegistForm.getUserEnablePage() + 
				"." + WebComponent.getServlet().getPageExt();
		
		Map<String, Object> m = new HashMap<String, Object>();
		m.put(UserInfoTable.Entity.ID_USER_ID, data.get(UserInfoTable.Entity.ID_USER_ID));
//		m.put(UserInfoTable.Entity.ID_LOGIN_ID, data.get(UserInfoTable.Entity.ID_LOGIN_ID));
		m.put(UserInfoTable.Entity.ID_MAIL_ADDRESS, data.get(UserInfoTable.Entity.ID_MAIL_ADDRESS));
//		m.put(UserInfoTable.Entity.ID_USER_NAME, data.get(UserInfoTable.Entity.ID_USER_NAME));
		String json = JSON.encode(m);
		String key = CryptUtil.encrypt(json, DataFormsServlet.getQueryStringCryptPassword());
		String enckey = java.net.URLEncoder.encode(key, DataFormsServlet.getEncoding());
		url += "?key=" + enckey;
		template.setLink("enableUserPage", url, url);
		Session session = MailSender.getMailSession();
		MailSender sender = new MailSender();
		sender.send(template, session);
	}
 
开发者ID:takayanagi2087,项目名称:dataforms,代码行数:38,代码来源:UserRegistForm.java

示例8: writeJsonTo

import net.arnx.jsonic.JSON; //导入方法依赖的package包/类
void writeJsonTo(Object obj, OutputStream ostream) throws IOException {
	String body = JSON.encode(obj, true);
	ostream.write(body.getBytes("UTF-8"));
	if (LOG.isDebugEnabled()) {
		LOG.debug("The following body written.");
		LOG.debug(body);
	}
}
 
开发者ID:o3project,项目名称:mlo-net,代码行数:9,代码来源:EtcAction.java

示例9: writeJsonTo

import net.arnx.jsonic.JSON; //导入方法依赖的package包/类
/**
 * Writes object to stream with json encoding.
 * @param obj An object.
 * @param ostream An stream written to
 * @throws IOException An exception in writing to stream.
 */
void writeJsonTo(Object obj, OutputStream ostream) throws IOException {
	String body = JSON.encode(obj, true);
	ostream.write(body.getBytes("UTF-8"));
	if (LOG.isDebugEnabled()) {
		LOG.debug("The following body written.");
		LOG.debug(body);
	}
}
 
开发者ID:o3project,项目名称:mlo-net,代码行数:15,代码来源:EtcAction.java

示例10: testGetRySwitches

import net.arnx.jsonic.JSON; //导入方法依赖的package包/类
/**
 * Test method for {@link org.o3project.mlo.server.impl.rpc.service.LdServiceImpl#getRySwitches()}.
 * @throws MloException 
 */
@Test
public void testGetRySwitches() throws MloException {
	List<RySwitchDto> rySwitchDtos = Arrays.asList(
			createRySwitchDto("0001", 
					createRyPortDto("name-0001-00", "port-0001-00", "mac-0001-00", "0001"),
					createRyPortDto("name-0001-01", "port-0001-01", "mac-0001-01", "0001"),
					createRyPortDto("name-0001-02", "port-0001-02", "mac-0001-02", "0001")
					),
			createRySwitchDto("0002", 
					createRyPortDto("name-0002-00", "port-0002-00", "mac-0002-00", "0002"),
					createRyPortDto("name-0002-01", "port-0002-01", "mac-0002-01", "0002")
					)
					);
	String resBody = JSON.encode(rySwitchDtos);
	LdServiceImpl obj = createObj(resBody);

	List<RySwitchDto> resDtos = obj.getRySwitches();
	
	RySwitchDto dto = null;
	assertEquals(2, resDtos.size());
	
	dto = resDtos.get(0);
	assertEquals("0001", dto.dpid);
	assertEquals(3, dto.ports.size());
	assertTrue(rySwitchDtos.get(0).ports.get(0) != dto.ports.get(0));
	assertEquals(rySwitchDtos.get(0).ports.get(0), dto.ports.get(0));
	assertTrue(rySwitchDtos.get(0).ports.get(1) != dto.ports.get(1));
	assertEquals(rySwitchDtos.get(0).ports.get(1), dto.ports.get(1));
	assertTrue(rySwitchDtos.get(0).ports.get(2) != dto.ports.get(2));
	assertEquals(rySwitchDtos.get(0).ports.get(2), dto.ports.get(2));
	
	dto = resDtos.get(1);
	assertEquals("0002", dto.dpid);
	assertEquals(2, dto.ports.size());
	assertTrue(rySwitchDtos.get(1).ports.get(0) != dto.ports.get(0));
	assertEquals(rySwitchDtos.get(1).ports.get(0), dto.ports.get(0));
	assertTrue(rySwitchDtos.get(1).ports.get(1) != dto.ports.get(1));
	assertEquals(rySwitchDtos.get(1).ports.get(1), dto.ports.get(1));
}
 
开发者ID:o3project,项目名称:mlo-net,代码行数:44,代码来源:LdServiceImplTest.java

示例11: testGetRyLinks

import net.arnx.jsonic.JSON; //导入方法依赖的package包/类
/**
 * Test method for {@link org.o3project.mlo.server.impl.rpc.service.LdServiceImpl#getRyLinks()}.
 * @throws MloException 
 */
@Test
public void testGetRyLinks() throws MloException {
	RyLinkDto[] ryLinkDtos = new RyLinkDto[]{
			createRyLinkDto(
					createRyPortDto("name-1001-00", "port-1001-00", "mac-1001-00", "1001"), 
					createRyPortDto("name-1001-01", "port-1001-01", "mac-1001-01", "1001")),
			createRyLinkDto(
					createRyPortDto("name-1002-00", "port-1002-00", "mac-1002-00", "1002"), 
					createRyPortDto("name-1002-01", "port-1002-01", "mac-1002-01", "1002")),
	};
	String resBody = JSON.encode(ryLinkDtos);
	
	LdServiceImpl obj = createObj(resBody);
	List<RyLinkDto> resDto = obj.getRyLinks();
	
	RyLinkDto dto = null;
	assertEquals(2, resDto.size());
	dto = resDto.get(0);
	assertTrue(ryLinkDtos[0].src != dto.src);
	assertEquals(ryLinkDtos[0].src, dto.src);
	assertTrue(ryLinkDtos[0].dst != dto.dst);
	assertEquals(ryLinkDtos[0].dst, dto.dst);
	dto = resDto.get(1);
	assertTrue(ryLinkDtos[1].src != dto.src);
	assertEquals(ryLinkDtos[1].src, dto.src);
	assertTrue(ryLinkDtos[1].dst != dto.dst);
	assertEquals(ryLinkDtos[1].dst, dto.dst);
	
}
 
开发者ID:o3project,项目名称:mlo-net,代码行数:34,代码来源:LdServiceImplTest.java

示例12: generateProfileFromText

import net.arnx.jsonic.JSON; //导入方法依赖的package包/类
/**
 * Generate Language Profile from Text File
 * <p>
 * <pre>
 * usage: --genprofile-text -l [language code] [text file path]
 * </pre>
 */
private void generateProfileFromText() {
    if (arglist.size() != 1) {
        System.err.println("Need to specify text file path");
        return;
    }
    File file = new File(arglist.get(0));
    if (!file.exists()) {
        System.err.println("Need to specify existing text file path");
        return;
    }

    String lang = get("lang");
    if (lang == null) {
        System.err.println("Need to specify langage code(-l)");
        return;
    }

    FileOutputStream os = null;
    try {
        LangProfile profile = GenProfile.loadFromText(lang, file);
        profile.omitLessFreq();

        File profile_path = new File(lang);
        os = new FileOutputStream(profile_path);
        JSON.encode(profile, os);
    } catch (JSONException | LangDetectException | IOException e) {
        e.printStackTrace();
    } finally {
        try {
            if (os != null) os.close();
        } catch (IOException ignored) {
        }
    }
}
 
开发者ID:malcolmgreaves,项目名称:language-detection,代码行数:42,代码来源:Command.java

示例13: toJSON

import net.arnx.jsonic.JSON; //导入方法依赖的package包/类
private static String toJSON(List<AddressCorresponGroup> addresses) throws Exception {
    return JSON.encode(addresses);
}
 
开发者ID:otsecbsol,项目名称:linkbinder,代码行数:4,代码来源:AddressValidatorTest.java

示例14: writeJson

import net.arnx.jsonic.JSON; //导入方法依赖的package包/类
static void writeJson(LdTopoDto topoConf, OutputStream jsonOutputStream) throws IOException {
	JSON.encode(topoConf, jsonOutputStream, true);
}
 
开发者ID:o3project,项目名称:mlo-net,代码行数:4,代码来源:LdConfJsonConverterTopoImpl.java

示例15: toJSON

import net.arnx.jsonic.JSON; //导入方法依赖的package包/类
public final String toJSON() {
    return JSON.encode(this);
}
 
开发者ID:nakaken0629,项目名称:iped,代码行数:4,代码来源:BaseResponse.java


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