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


Java JSONArray.toJSONString方法代码示例

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


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

示例1: saveResults

import net.minidev.json.JSONArray; //导入方法依赖的package包/类
public void saveResults() {
expert2score = Application.sortByValue(node2pagescore);

JSONArray jsonArray = new JSONArray();

for (String userid : expert2score.keySet()) {
    if (super.MAX_RESULTS > 0) {
	UserEntity user = super.usermap.get(Long.parseLong(userid));
	user.setScore(node2pagescore.get(userid));

	ArrayList<String> labels = super.jcreator.getConnectedLabels(userid);
	user.setRelatedPosts(labels);

	if (user != null) {
	    jsonArray.add(user);
	}
    } else {
	break;
    }
    super.MAX_RESULTS--;
}

experts = jsonArray.toJSONString();
super.save(expert2score, experts);
   }
 
开发者ID:learning-layers,项目名称:Expert-Identification-Service,代码行数:26,代码来源:PageRankStrategy.java

示例2: getExperts

import net.minidev.json.JSONArray; //导入方法依赖的package包/类
public String getExperts() {
	LinkedHashMap<String, Double> experts = Application
			.sortByValue(userId2Score);

	int i = 0;
	JSONArray jsonArray = new JSONArray();

	// for (String userid : experts.keySet()) {
	// i++;
	// // Restrict result to 10 items for now.
	// if (i < 10) {
	// User user = Application.userId2userObj.get(userid);
	//
	// // TODO: Change to setScore.
	// user.setRank(String.valueOf(userId2Score.get(userid)));
	// if (user != null) {
	// jsonArray.add(user);
	// }
	// } else {
	// break;
	// }
	// }

	return jsonArray.toJSONString();
}
 
开发者ID:learning-layers,项目名称:Expert-Identification-Service,代码行数:26,代码来源:UserModelingStrategy.java

示例3: saveResults

import net.minidev.json.JSONArray; //导入方法依赖的package包/类
@Override
   public void saveResults() {
expert2score = Application.sortByValue(node2hitsscore);

JSONArray jsonArray = new JSONArray();

for (String userid : expert2score.keySet()) {
    // Restrict result to 10 items for now.
    if (super.MAX_RESULTS > 0) {
	UserEntity user = super.usermap.get(Long.parseLong(userid));
	user.setScore(node2hitsscore.get(userid));

	if (user != null) {
	    jsonArray.add(user);

	}
	super.MAX_RESULTS--;
    }
}
experts = jsonArray.toJSONString();
super.save(expert2score, experts);

   }
 
开发者ID:learning-layers,项目名称:Expert-Identification-Service,代码行数:24,代码来源:CommunityAwareHITSStrategy.java

示例4: saveResults

import net.minidev.json.JSONArray; //导入方法依赖的package包/类
public void saveResults() {
expert2score = Application.sortByValue(node2hitsscore);

JSONArray jsonArray = new JSONArray();

for (String userid : expert2score.keySet()) {
    if (super.MAX_RESULTS > 0) {
	UserEntity user = super.usermap.get(Long.parseLong(userid));
	user.setScore(node2hitsscore.get(userid));

	ArrayList<String> labels = super.jcreator.getConnectedLabels(userid);
	user.setRelatedPosts(labels);

	if (user != null) {
	    jsonArray.add(user);
	}
    } else {
	break;
    }
    super.MAX_RESULTS--;
}

experts = jsonArray.toJSONString();

super.save(expert2score, experts);
   }
 
开发者ID:learning-layers,项目名称:Expert-Identification-Service,代码行数:27,代码来源:HITSStrategy.java

示例5: saveResults

import net.minidev.json.JSONArray; //导入方法依赖的package包/类
@Override
   public void saveResults() {
expert2score = Application.sortByValue(node2hitsscore);

int count = 0;
JSONArray jsonArray = new JSONArray();

for (String userid : expert2score.keySet()) {
    // Restrict result to 10 items for now.
    if (count < 10) {
	UserEntity user = super.usermap.get(Long.parseLong(userid));
	user.setScore(node2hitsscore.get(userid));

	if (user != null) {
	    jsonArray.add(user);

	} else {
	    break;
	}
	count++;
    }
}
experts = jsonArray.toJSONString();
super.save(expert2score, experts);

   }
 
开发者ID:rwth-acis,项目名称:Expert-Recommender-Service,代码行数:27,代码来源:CommunityAwareHITSStrategy.java

示例6: toJson

import net.minidev.json.JSONArray; //导入方法依赖的package包/类
@Override
public String toJson(Object obj) {

    if (obj instanceof Map) {
        return JSONObject.toJSONString((Map<String, ?>) obj, JSONStyle.LT_COMPRESS);
    } else if (obj instanceof List) {
        return JSONArray.toJSONString((List<?>) obj, JSONStyle.LT_COMPRESS);
    } else {
        throw new UnsupportedOperationException(obj.getClass().getName() + " can not be converted to JSON");
    }
}
 
开发者ID:osswangxining,项目名称:another-rule-based-analytics-on-spark,代码行数:12,代码来源:JsonSmartJsonProvider.java

示例7: getExperts

import net.minidev.json.JSONArray; //导入方法依赖的package包/类
public String getExperts() {
ArrayList<String> relatedPosts = new ArrayList();
JSONArray jsonArray = new JSONArray();
try {
    expert2score = Application.sortByValue(userId2score);

    int i = 0;

    for (long userid : expert2score.keySet()) {

	// Restrict result to 10 items for now.
	if (i < 10) {
	    UserEntity user = userId2userObj.get(userid);
	    user.setScore(userId2score.get(userid));
	    relatedPosts.addAll(userId2postIds.get(userid));
	    user.setRelatedPosts(relatedPosts);
	    if (user != null) {
		jsonArray.add(user);
	    }
	} else {
	    break;
	}
	i++;
    }
} catch (Exception e) {
    e.printStackTrace();
}

return jsonArray.toJSONString();
   }
 
开发者ID:learning-layers,项目名称:Expert-Identification-Service,代码行数:31,代码来源:DataModelingStrategy.java

示例8: saveResults

import net.minidev.json.JSONArray; //导入方法依赖的package包/类
@Override
   public void saveResults() {
expert2score = Application.sortByValue(node2hitsscore);

int count = 0;
JSONArray jsonArray = new JSONArray();
// ArrayList expertScores = new ArrayList<Double>();
for (String userid : expert2score.keySet()) {
    count++;
    // Restrict result to 10 items for now.
    if (count < 10) {
	UserEntity user = super.usermap.get(Long.parseLong(userid));
	user.setScore(node2hitsscore.get(userid));

	ArrayList<String> labels = super.jcreator.getConnectedLabels(userid);
	user.setRelatedPosts(labels);

	// String result = String.format("%.14f",
	// node2hitsscore.get(userid));
	// System.out.println("CPageRAnk Score -- "+result);
	// System.out.println("CPageRAnk Score Rounded:: "+Application.roundDouble(node2hitsscore.get(userid)));
	// expertScores.add(node2hitsscore.get(userid));
	if (user != null) {
	    jsonArray.add(user);
	}

    } else {
	break;
    }

}

// Application.writeListToFile(expertScores);

experts = jsonArray.toJSONString();

super.save(expert2score, experts);

   }
 
开发者ID:rwth-acis,项目名称:Expert-Recommender-Service,代码行数:40,代码来源:CommunityAwarePageRankStrategy.java

示例9: saveResults

import net.minidev.json.JSONArray; //导入方法依赖的package包/类
public void saveResults() {
expert2score = Application.sortByValue(node2pagescore);

int count = 0;
JSONArray jsonArray = new JSONArray();

for (String userid : expert2score.keySet()) {
    count++;
    // Restrict result to 10 items for now.
    if (count < 10) {
	UserEntity user = super.usermap.get(Long.parseLong(userid));
	user.setScore(node2pagescore.get(userid));

	ArrayList<String> labels = super.jcreator.getConnectedLabels(userid);
	user.setRelatedPosts(labels);

	if (user != null) {
	    jsonArray.add(user);
	}
    } else {
	break;
    }
}

experts = jsonArray.toJSONString();
super.save(expert2score, experts);
   }
 
开发者ID:rwth-acis,项目名称:Expert-Recommender-Service,代码行数:28,代码来源:PageRankStrategy.java

示例10: getLeroyBuilderJSON

import net.minidev.json.JSONArray; //导入方法依赖的package包/类
public static String getLeroyBuilderJSON(String json) {
    JSONArray props = JsonPath.read(json, LEROY_BUILDER_JPATH);
    if (props != null) {
        return props.toJSONString();
    }
    return "";
}
 
开发者ID:epicforce,项目名称:leroy_jenkins,代码行数:8,代码来源:JsonUtils.java

示例11: getParametersJSON

import net.minidev.json.JSONArray; //导入方法依赖的package包/类
public static String getParametersJSON(String json) {
    JSONArray props = JsonPath.read(json, LEROY_BUILDER_PARAMETERS_JPATH);
    if (props != null) {
        return props.toJSONString();
    }
    return "";
}
 
开发者ID:epicforce,项目名称:leroy_jenkins,代码行数:8,代码来源:JsonUtils.java

示例12: saveResults

import net.minidev.json.JSONArray; //导入方法依赖的package包/类
public void saveResults() {
expert2score = Application.sortByValue(node2hitsscore);

int i = 0;
JSONArray jsonArray = new JSONArray();

for (String userid : expert2score.keySet()) {
    i++;
    // Restrict result to 10 items for now.
    if (i < 10) {
	UserEntity user = super.usermap.get(Long.parseLong(userid));
	user.setScore(node2hitsscore.get(userid));

	ArrayList<String> labels = super.jcreator.getConnectedLabels(userid);
	user.setRelatedPosts(labels);

	// try {
	// HashMap<String, Integer> tag2count = new HashMap<String,
	// Integer>();
	// if (labels != null && labels.size() > 0) {
	// for (String label : labels) {
	// if (label != null) {
	// String tags = super.dbHandler.getSemanticTags(label);
	// if (tags != null && tags.length() > 0) {
	// String[] tagAr = tags.split(",");
	// if (tagAr != null && tagAr.length > 0) {
	// for (String tag : tagAr) {
	// System.out.println("TAG:: ");
	// if (tag != null && tag.length() > 0) {
	// // System.out.println("TAG:: " +
	// // tag);
	// if (tag2count.containsKey(tag)) {
	// tag2count.put(tag, tag2count.get(tag) + 1);
	// } else {
	// tag2count.put(tag, 1);
	// }
	// }
	// }
	// }
	// }
	// }
	//
	// }
	//
	// LinkedHashMap<String, Integer> tag2countSorted =
	// Application.sortByValue(tag2count);
	// // StringBuilder actualTags = new StringBuilder();
	// Iterator<String> it1 = tag2countSorted.keySet().iterator();
	// int count = 0;
	// ArrayList<String> reqTags = new ArrayList<String>();
	// while (it1.hasNext() && count < 3) {
	// reqTags.add(it1.next());
	// count++;
	// }
	//
	// user.setTags(Joiner.on(",").join(reqTags));
	// }
	// } catch (Exception e) {
	// System.out.print(e.toString());
	// }

	if (user != null) {
	    jsonArray.add(user);
	}
    } else {
	break;
    }
}

experts = jsonArray.toJSONString();

System.out.println(experts);

super.save(expert2score, experts);
   }
 
开发者ID:rwth-acis,项目名称:Expert-Recommender-Service,代码行数:76,代码来源:HITSStrategy.java

示例13: saveResults

import net.minidev.json.JSONArray; //导入方法依赖的package包/类
@Override
   public void saveResults() {
expert2score = Application.sortByValue(node2hitsscore);

JSONArray jsonArray = new JSONArray();
for (String userid : expert2score.keySet()) {

    if (super.MAX_RESULTS > 0) {
	UserEntity user = super.usermap.get(Long.parseLong(userid));
	user.setScore(node2hitsscore.get(userid));

	ArrayList<String> labels = super.jcreator.getConnectedLabels(userid);
	user.setRelatedPosts(labels);

	if (user != null) {
	    jsonArray.add(user);
	}

    } else {
	break;
    }

    super.MAX_RESULTS--;

}

experts = jsonArray.toJSONString();

super.save(expert2score, experts);

   }
 
开发者ID:learning-layers,项目名称:Expert-Identification-Service,代码行数:32,代码来源:CommunityAwarePageRankStrategy.java


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