Created
January 29, 2015 01:44
-
-
Save toguri/00a66bc5d085583dd9eb to your computer and use it in GitHub Desktop.
JSON作成時に、特定の機種のみで発生してたこと
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
public class MainActivity extends ActionBarActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
/* | |
JSON作成時に、特定の機種のみで発生してたこと | |
SH-04E (4.1.2)の場合 | |
{"hoge":["111111111","2222222222","3333333333"]} | |
{"foo":"[111111111, 2222222222, 3333333333]"} | |
Nexus5 (4.4.4)の場合 | |
{"hoge":["111111111","2222222222","3333333333"]} | |
{"foo":["111111111", "2222222222", "3333333333"]} | |
*/ | |
ArrayList<String> arrayList = new ArrayList<String>(); | |
arrayList.add("111111111"); | |
arrayList.add("2222222222"); | |
arrayList.add("3333333333"); | |
JSONArray jsonArray = new JSONArray(arrayList); | |
// JSONArrayに変換してからつっこむ | |
HashMap<String, Object> map = new HashMap<String, Object>(1); | |
map.put("hoge", jsonArray); | |
Log.d("MainActivity", new JSONObject(map).toString()); | |
// ArrayListに変換してからつっこむ | |
HashMap<String, Object> map2 = new HashMap<String, Object>(1); | |
map2.put("foo", arrayList); | |
Log.d("MainActivity", new JSONObject(map2).toString()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment