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


Java JSON类代码示例

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


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

示例1: 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

示例2: decodeAddressCorresponGroup

import net.arnx.jsonic.JSON; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private List<DistTemplateGroup> decodeAddressCorresponGroup(String value, boolean to) {
    if (StringUtils.isEmpty(value)) {
        return new ArrayList<DistTemplateGroup>();
    }

    List<DistTemplateGroup> addresses =
        (List<DistTemplateGroup>) JSON.decode(value, getMappingType());
    Long dgOrderNo = 0L;
    for (DistTemplateGroup dg : addresses) {
        dg.setDistributionType(to ? DistributionType.TO : DistributionType.CC);
        dg.setOrderNo(dgOrderNo++);
        List<DistTemplateUser> users = dg.getUsers();
        if (users == null) {
            continue;
        }
        Long duOrderNo = 0L;
        for (DistTemplateUser du : users) {
            du.setDistTemplateGroupId(dg.getId());
            du.setOrderNo(duOrderNo++);
        }
    }
    return addresses;
}
 
开发者ID:otsecbsol,项目名称:linkbinder,代码行数:25,代码来源:DistributionTemplateEditPage.java

示例3: testDtoToJSON1

import net.arnx.jsonic.JSON; //导入依赖的package包/类
@Test
public void testDtoToJSON1() {

    User u;
    List<User> users = new ArrayList<User>();
    Map<String, User> userMap = new HashMap<String, User>();

    u = new User();
    u.setEmpNo("ZZA01");
    u.setNameE("Taro Yamada");

    users.add(u);
    userMap.put(u.getEmpNo(), u);

    u = new User();
    u.setEmpNo("ZZA02");
    u.setNameE("Jiro Yamada");

    users.add(u);
    userMap.put(u.getEmpNo(), u);

    System.out.println(JSON.encode(users, true));
    System.out.println(JSON.encode(userMap, true));
}
 
开发者ID:otsecbsol,项目名称:linkbinder,代码行数:25,代码来源:JSONICTest.java

示例4: testDtoToJSON2

import net.arnx.jsonic.JSON; //导入依赖的package包/类
@Test
public void testDtoToJSON2() {

    CorresponGroup g;
    List<CorresponGroup> groups = new ArrayList<CorresponGroup>();
    Map<Long, CorresponGroup> groupMap = new HashMap<Long, CorresponGroup>();

    g = new CorresponGroup();
    g.setId(1L);
    g.setName("YOC:IT");

    groups.add(g);
    groupMap.put(g.getId(), g);

    g = new CorresponGroup();
    g.setId(2L);
    g.setName("YOC:PIPING");

    groups.add(g);
    groupMap.put(g.getId(), g);

    System.out.println(JSON.encode(groups, true));
    System.out.println(JSON.encode(groupMap));
}
 
开发者ID:otsecbsol,项目名称:linkbinder,代码行数:25,代码来源:JSONICTest.java

示例5: testDtoToJSON3

import net.arnx.jsonic.JSON; //导入依赖的package包/类
@Test
public void testDtoToJSON3() {

    CorresponGroup g;
    List<CorresponGroup> groups = new ArrayList<CorresponGroup>();
    Map<Long, CorresponGroup> groupMap = new HashMap<Long, CorresponGroup>();

    g = new CorresponGroup();
    g.setId(1L);
    g.setName("YOC:IT\"");

    groups.add(g);
    groupMap.put(g.getId(), g);

    g = new CorresponGroup();
    g.setId(2L);
    g.setName("YOC:PIPING");

    groups.add(g);
    groupMap.put(g.getId(), g);

    System.out.println(JSON.encode(groups, true));
    System.out.println(JSON.encode(groupMap));
}
 
开发者ID:otsecbsol,项目名称:linkbinder,代码行数:25,代码来源:JSONICTest.java

示例6: testJSONToObject2

import net.arnx.jsonic.JSON; //导入依赖的package包/类
@Test
public void testJSONToObject2() throws Exception {
    String json =
        "[{corresponGroupId:\"1\",users:[{empNo:\"ZZA01\"},{empNo:\"ZZA02\"}]}," +
        "{corresponGroupId:\"2\",users:[{empNo:\"ZZA03\"},{empNo:\"ZZA04\"}]}]";

    List<CorresponGroupUserMapping> mappings =
        (List<CorresponGroupUserMapping>)
                JSON.decode(json,
                            getClass().getField("m").getGenericType());


    assertEquals(2, mappings.size());
    for (CorresponGroupUserMapping m : mappings) {
        System.out.println(m);
    }
}
 
开发者ID:otsecbsol,项目名称:linkbinder,代码行数:18,代码来源:JSONICTest.java

示例7: testMappings

import net.arnx.jsonic.JSON; //导入依赖的package包/类
@Test
public void testMappings() throws Exception {
    List<AddressCorresponGroup> list = new ArrayList<AddressCorresponGroup>();
    List<AddressUser> aul = new ArrayList<AddressUser>();
    AddressCorresponGroup ag;
    CorresponGroup g;
    AddressUser au;
    User u;

    ag = new AddressCorresponGroup();
    g = new CorresponGroup();
    g.setId(1L);
    ag.setCorresponGroup(g);

    aul = new ArrayList<AddressUser>();
    au = new AddressUser();
    u = new User();
    u.setEmpNo("ZZA01");
    au.setUser(u);
    aul.add(au);

    ag.setUsers(aul);
    list.add(ag);

    System.out.println(JSON.encode(list));
}
 
开发者ID:otsecbsol,项目名称:linkbinder,代码行数:27,代码来源:JSONICTest.java

示例8: testMappings

import net.arnx.jsonic.JSON; //导入依赖的package包/类
@Test
    public void testMappings() throws Exception {
        List<AddressCorresponGroup> list = new ArrayList<AddressCorresponGroup>();
        List<AddressUser> aul = new ArrayList<AddressUser>();
        AddressCorresponGroup ag;
        CorresponGroup g;
        AddressUser au;
        User u;

        ag = new AddressCorresponGroup();
        g = new CorresponGroup();
        g.setId(1L);
        ag.setCorresponGroup(g);

        aul = new ArrayList<AddressUser>();
        au = new AddressUser();
        u = new User();
        u.setEmpNo("ZZA01");
        au.setUser(u);
        aul.add(au);
//
        ag.setUsers(aul);
        list.add(ag);

        System.out.println(JSON.encode(list));
    }
 
开发者ID:otsecbsol,项目名称:linkbinder,代码行数:27,代码来源:JSONICTest.java

示例9: print

import net.arnx.jsonic.JSON; //导入依赖的package包/类
/**
 * 印刷処理を行います。
 * @param param パラメータ。
 * @return 応答。
 * @throws Exception 例外。
 */
@WebMethod
public Response print(final Map<String, Object> param) throws Exception {
	this.methodStartLog(log, param);
	Map<String, Object> data = this.convertToServerData(param);
	@SuppressWarnings("unchecked")
	List<Map<String, Object>> list = (List<Map<String, Object>>) data.get("attachFileTable");
	for (int i = 0; i < list.size(); i++) {
		Map<String, Object> m = list.get(i);
		m.put("no", Integer.valueOf(i + 1));
		m.put("barcode", this.getBarcodeImage(Integer.toString(123450000 + i)));
	}
	log.debug("data=" + JSON.encode(data, true));
	String template = AllTypeEditForm.getServlet().getServletContext().getRealPath("/exceltemplate/alltypeExcelTempl.xlsx");
	log.debug("template=" + template);
	AlltypeExcelReport rep = new AlltypeExcelReport(template);
	byte[] excel = rep.print(data);
	BinaryResponse ret = new BinaryResponse(excel);
	ret.setFileName("test001.xlsx");
	this.methodFinishLog(log, ret);
	return ret;
}
 
开发者ID:takayanagi2087,项目名称:dataforms,代码行数:28,代码来源:AllTypeEditForm.java

示例10: 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

示例11: getInitialData

import net.arnx.jsonic.JSON; //导入依赖的package包/类
/**
 * 初期化データを取得します。
 * <pre>
 * クラスと同一パスにある&lt;TableClassName&gt;.data.jsonというファイルを読み込みます。
 * </pre>
 * @return 初期化データ。
 * @throws Exception 例外。
 */
@SuppressWarnings("unchecked")
public List<Map<String, Object>> getInitialData() throws Exception {
	List<Map<String, Object>> list = null;
	Class<?> cls = this.getClass();
	InputStream is = cls.getResourceAsStream("data/" + cls.getSimpleName() + ".data.json");
	if (is != null) {
		try {
			String json = new String(FileUtil.readInputStream(is), DataFormsServlet.getEncoding());
			list = (List<Map<String, Object>>) JSON.decode(json);
		} finally {
			is.close();
		}
	}
	return list;
}
 
开发者ID:takayanagi2087,项目名称:dataforms,代码行数:24,代码来源:Table.java

示例12: loadDtoFromResource

import net.arnx.jsonic.JSON; //导入依赖的package包/类
private <DTO> DTO loadDtoFromResource(String path, Class<DTO> dtoClass) throws MloException {
	DTO dto = null;
	InputStream inputStream = null;
	URL url = ResourceUtil.getResource(path);
	try {
		try {
			inputStream = url.openStream();
			dto = JSON.decode(inputStream, dtoClass);
		} finally {
			if (inputStream != null) {
				inputStream.close();
				inputStream = null;
			}
		}
	} catch (IOException e) {
		LOG.error("Unexpected situation.", e);
		throw new InternalException("Unexpected situation.", e);
	}
	return dto;
}
 
开发者ID:o3project,项目名称:mlo-net,代码行数:21,代码来源:LdServiceImpl.java

示例13: loadProfile

import net.arnx.jsonic.JSON; //导入依赖的package包/类
/**
 * Load profiles from specified directory.
 * This method must be called once before language detection.
 *
 * @param json_profiles all json-encoded profiles
 * @throws LangDetectException Can't open profiles(error code = {@link ErrorCode#FileLoadError})
 *                             or profile's format is wrong (error code = {@link ErrorCode#FormatError})
 */
public void loadProfile(final List<String> json_profiles) throws LangDetectException {
    final int langsize = json_profiles.size();
    if (langsize < 2)
        throw new LangDetectException(ErrorCode.NeedLoadProfileError, "Need more than 2 profiles");

    int index = 0;
    for (final String json : json_profiles) {
        try {
            final LangProfile profile = JSON.decode(json, LangProfile.class);
            addProfile(profile, index, langsize);
            ++index;
        } catch (JSONException e) {
            throw new LangDetectException(ErrorCode.FormatError, "profile format error");
        }
    }
}
 
开发者ID:malcolmgreaves,项目名称:language-detection,代码行数:25,代码来源:DetectorFactory.java

示例14: 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

示例15: processedMessage

import net.arnx.jsonic.JSON; //导入依赖的package包/类
@Override
protected List<String> processedMessage(final String key,
        final Map<String, String> param) {
    final AccountContext ac = Contexts.get(AccountContext.class);
    final long now = System.currentTimeMillis();
    final String lastTimeStr = param.get("lastTime");
    final long lastTime = lastTimeStr != null ? Long.valueOf(lastTimeStr) : now;
    final CacheManager cm = CacheManagerFactory.getCacheManager();
    final Cache<Long, String> cache = cm.getCache("webNotificationsBroadcastCache");
    final List<String> messages = new ArrayList<>();
    for (Cache.Entry<Long, String> entry : cache)
        if (entry.getKey() > lastTime) {
            final Map<String, String> message = new HashMap<>();
            message.put("userCd", ac.getUserCd());
            message.put("value", entry.getValue());
            messages.add(JSON.encode(message));
        }
    processTime = now;
    lastProcessTime = lastTime != now ? lastTime : now;
    return messages;
}
 
开发者ID:Global-Solutions,项目名称:web_notifications,代码行数:22,代码来源:BroadcastTask.java


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