因此,我编写了一些代码来根据查询搜索reddits api,并且希望它也显示注释。我的$.getJSON语句中嵌套了以下代码,该语句根据您的搜索查询提取每个标题/帖子,现在我想为找到的每个结果显示注释树(因此,为什么将其嵌套在我的原始getJSON语句中)
$.getJSON("http://www.reddit.com/r/" + sub + "/comments/" + id + ".json?", function (data){
$.each(data.data.children, function (i, item) {
var comment = item.data.body
var author = item.data.author
var postcomment = '<p>[Author]' + author + '<br>' + comment + '</p>'
results.append(postcomment)
});
});
Run Code Online (Sandbox Code Playgroud)
我觉得我可能在构造$.each错误的陈述或其他内容。我只是遵循我对其他getJSON语句所做的操作。有任何想法吗?
我正在尝试使用reddit的api实现搜索,但是没有太多运气:
http://www.reddit.com/search.json?q=ferrari?jsonp=?
Run Code Online (Sandbox Code Playgroud)
它返回一些json格式的文本但没有结果..如果我搜索"cars",它返回2个结果,我的其余代码将无法识别对象.(另外,我知道汽车的结果超过2个).有关如何修改URL的任何想法?
我有一个包含多个LinkedList对象的数组列表.我的主要代码是:
import java.io.*;
import java.util.AbstractList;
import java.util.*;
public class Sort {
public static void main (String[] args){
int listNum = 0;
File file = new File("input.txt");
ArrayList<LinkedList> my_lists = new ArrayList<LinkedList>();
try {
Scanner sc = new Scanner(file);
while (sc.hasNextLine()) {
System.out.println("List" + listNum);
String line = sc.nextLine();
LinkedList the_list = new LinkedList();
String[] templist = line.split("\\s*,\\s*");
for(int i=0; i<templist.length; i++){
String temp = templist[i];
the_list.add(temp);
System.out.println(temp);
}
listNum++;
my_lists.add(the_list);
}
sc.close();
}
catch (FileNotFoundException e) {
e.printStackTrace();
}
for(int …Run Code Online (Sandbox Code Playgroud)