java 數組字符串和數組互轉

1.數組字符串轉數組

    @Test
    public void testStrToArr() throws ParseException {
        String abc  = "[\"multi_task\",\"rest_time\"]";
        Object object = JSON.parse(abc);
    }

2.數組轉數組字符串

    @Test
    public void testArrToStr(){
        String[] arr = {"a", "b", "c"};
        JSONObject.toJSONString(arr);//["a","b","c"]
    }

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章