Created
April 18, 2016 03:37
-
-
Save spiral6/a9946b8bbdd7edf2fcc467a1a5ff2fbc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Comment class | |
import java.util.List; | |
import java.util.Map; | |
import com.fasterxml.jackson.annotation.JsonProperty; | |
public class redditComment { | |
@JsonProperty("data") | |
private List<redditCommentData> data; | |
public Object getdata() { | |
return data; | |
} | |
public void setdata(List<redditCommentData> data) { | |
this.data = data; | |
} | |
public String toString(){ | |
return "\n" + data; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//commentCreator class | |
import java.io.IOException; | |
import java.net.URL; | |
import java.nio.file.Files; | |
import java.nio.file.Paths; | |
import java.util.List; | |
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | |
import com.fasterxml.jackson.core.type.TypeReference; | |
import com.fasterxml.jackson.databind.DeserializationFeature; | |
import com.fasterxml.jackson.databind.JsonNode; | |
import com.fasterxml.jackson.databind.ObjectMapper; | |
import com.fasterxml.jackson.databind.node.ArrayNode; | |
import com.fasterxml.jackson.databind.node.ObjectNode; | |
public class redditCommentCreator { | |
public static void main(String[] args) throws IOException { | |
ObjectMapper mapper = new ObjectMapper(); | |
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |
List<redditComment> comments = mapper.readValue(new URL("https://api.pushshift.io/reddit/search/comment?q=yang&subreddit=rwby&limit=3"), new TypeReference<List<redditComment>>() {}); | |
System.out.println(containers.size()); | |
for(redditComment comment : comments) { | |
System.out.println("Container Id : " + comment.getdata()); | |
} | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//CommentData class | |
import java.util.List; | |
import java.util.Map; | |
import com.fasterxml.jackson.annotation.JsonProperty; | |
public class redditCommentData { | |
@JsonProperty("body") | |
private String body; | |
@JsonProperty("link_permalink") | |
private String link_permalink; | |
public String getBody(){ | |
return body; | |
} | |
public String getlink(){ | |
return link_permalink; | |
} | |
public void setBody(String body){ | |
this.body = body; | |
} | |
public void setlink(String link_permalink){ | |
this.link_permalink = link_permalink; | |
} | |
public String toString(){ | |
return body + "\n" + link_permalink; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment