私は現在、OpinionatedというオープンソースプロジェクトのAndroidフロントエンドで作業しています。これは私の最初のアンドロイド開発の経験です。このアプリは、ニュースアグリゲーターであり、読者が読んでいる記事と同様の記事にリンクしています。バックエンドは、ボタン/テキストビューなどを作成するために解析する必要のあるJSONファイルを生成します。Android用JSONファイルの解析に問題がある
私はアンドロイドプロジェクトのassetsフォルダにJSONファイルを格納していますが、JSONの内容を返す関数があります。ファイルを文字列として返します。この文字列を使用してJSONObjectを作成しますが、この文字列を使用してJSONArrayを作成しようとすると例外がスローされます。
私のJSONファイルは次のようになります。次のようにJSONオブジェクトを作成し、使用しています
{
"article":{
"title" : "Justices Hearing Arguments on ‘One Person, One Vote’",
"description" : "The Supreme Court will address a voting rights case that has the potential to shift political power from urban areas to rural ones. The Supreme Court has never definitively ruled on who must be counted in voting districts: all residents or just eligible voters?",
"author" : "ADAM LIPTAK",
"date" : "2015-12-08",
"link" : "http://www.nytimes.com/2015/12/09/us/politics/supreme-court-to-hear-arguments-on-one-person-one-vote.html?hp&action=click&pgtype=Homepage&clickSource=story-heading&module=first-column-region®ion=top-news&WT.nav=top-news",
"image" : "http://static01.nyt.com/images/2015/12/08/us/09scotus-web/09scotus-web-master675.jpg",
"imageCaption" : "Voters in Columbus, Ohio, last month",
"body" : "WASHINGTON — A closely divided Supreme Court on Tuesday struggled to decide “what kind of democracy people want,” as Justice Stephen G. Breyer put it during an argument over the meaning of the constitutional principle of “one person one vote.” The case basic question in the case, Evenwel v. Abbott, No. 14-940, is who must be counted in drawing voting districts: all residents or just eligible voters? The difference matters, because people who are not eligible to vote — children, immigrants here legally who are not citizens, unauthorized immigrants, people disenfranchised for committing felonies, prisoners — are not spread evenly across the country. With the exception of prisoners, they tend to be concentrated in urban areas. Their presence amplifies the voting power of people eligible to vote in urban areas, usually helping Democrats. Rural areas that lean Republican, by contrast, usually have higher percentages of residents eligible to vote. Continue reading the main story. RELATED COVERAGE Q. and A.: Examining a Voting Rights CaseDEC. 8, 2015 The John J. Moran Medium Security Prison in Cranston, R.I. A lawsuit filed in that state by the American Civil Liberties Union objects to counting prisoners when drawing voting districts.Sidebar: A.C.L.U.’s Own Arguments May Work Against It in Voting Rights CaseOCT. 12, 2015 Voting booths in Houston. Two Texas plaintiffs are challenging State Senate districts apportioned by the number of residents rather than eligible voters, saying it dilutes their voting power.Supreme Court Agrees to Settle Meaning of ‘One Person One Vote’MAY 26, 2015 The court’s decision in the case, expected by June, has the potential to shift political power from urban areas to rural ones, a move that would provide a big boost to Republican voters in many parts of the nation. Chief Justice John G. Roberts Jr. seemed attracted to counting only voters. “It is called ‘one person one vote,’” he said. “That does seem designed to protect voters.” But Justice Sonia Sotomayor said there were other interests at stake. “There’s a voting interest,” she said, “but there is also a representational interest.” Continue reading the main story RELATED IN OPINION Contributing Op-Ed Writer: The Supreme Court’s Identity Crisis on Voting RightsMARCH 19, 2015 Justice Anthony M. Kennedy seemed to be looking for a middle ground. “You should at least give some consideration to the disparity you have among voters” in different voting districts, he said. The “one person one vote” principle, rooted in cases from the 1960s that revolutionized democratic representation in the United States, applies to the entire American political system aside from the Senate, where voters from states with small populations have vastly more voting power than those with large ones. Everywhere else, voting districts must have very close to the same populations. But the Supreme Court has never definitively ruled on who must be counted. Tuesday’s case, a challenge to voting districts for the Texas Senate, was brought by Sue Evenwel and Edward Pfenninger. They are represented by the Project on Fair Representation, a small conservative advocacy group that has been active in cases concerning race and voting. The group was on the winning side in 2013 in Shelby County v. Holder, which effectively struck down the heart of the Voting Rights Act, freeing nine states, mostly in the South, to change their election laws without advance federal approval. The group is also behind a challenge to affirmative action in admissions at the University of Texas at Austin to be argued on Wednesday. In court papers, Ms. Evenwel and Mr. Pfenninger said that they lived in “districts among the most overpopulated with eligible voters” and that “there are voters or potential voters in Texas whose Senate votes are worth approximately one and one-half times that of appellants.” Last year, a three-judge panel of the Federal District Court in Austin dismissed the case, saying that “the Supreme Court has generally used total population as the metric of comparison.” At the same time, the panel said, the Supreme Court has never required any particular standard. The choice, the panel said, belongs to the states. Continue reading the main story RECENT COMMENTS John Graubard 18 minutes ago At the time the Constitution was adopted only white property owning male citizens had the right to vote. Should we go back to that time? ... michjas 18 minutes ago Most of the non-voting population at issue here consists of the U.S.'s 75 million children. And of that total, 20 million are Hispanic,... raduray 18 minutes ago If we counted only voters, it would favor communities with smaller families (generally more liberal), as children don't vote. Plaintiffs,... SEE ALL COMMENTS WRITE A COMMENT Almost all states and localities count everyone, and the Constitution requires “counting the whole number of persons in each state” for apportioning seats in the House of Representatives among the states. There are practical problems, many political scientists say, in finding reliable data to count only eligible voters. Federal appeals courts have uniformly ruled that counting everyone is permissible, and one court has indicated that it is required. In the process, though, several judges have acknowledged that the Supreme Court’s decisions provide support for both approaches. The federal appeals court in New Orleans said the issue “presents a close question,” partly because the Supreme Court had been “somewhat evasive in regard to which population must be equalized.” In 1990, Judge Alex Kozinski, in a partial dissent from a decision of the federal appeals court in San Francisco, said there were respectable arguments on both sides. CONTINUE READING THE MAIN STORY 341 COMMENTS Counting everyone, he said, ensures “representational equality,” with elected officials tending to the interests of the same number of people, whether they are voters or not. Counting only eligible voters, on the other hand, he said, vindicates the principle that voters “hold the ultimate political power in our democracy.” In 2001, the Supreme Court turned down an opportunity to decide the question, in another case from Texas. “The one-person-one-vote principle may, in the end, be of little consequence if we decide that each jurisdiction can choose its own measure of population,” Justice Clarence Thomas wrote. “But as long as we sustain the one-person-one-vote principle, we have an obligation to explain to states and localities what it actually means.”",
"file" : "exArt1.json",
"template" : "top",
"similarArticles" : ["exArt4.json", "exArt5.json"]}}
私のコードは次のとおりです。
try {
JSONObject main_obj = new JSONObject(loadJSONFromAsset());
JSONArray jarray= main_obj.getJSONArray("article");
JSONObject article = jarray.getJSONObject(0);
String title=article.getString("title");
Button button = new Button(this);
button.setText(title);
linearLayout.addView(button);
} catch (JSONException e) {
e.printStackTrace();
}
すべてのヘルプ/ポインターは最も評価、おかげだろう!
、記事が – poss