第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何將字符串值轉換為 json?

如何將字符串值轉換為 json?

哆啦的時光機 2022-09-07 18:00:24
我有一個用逗號和“=”分隔的值字符串。我需要將其轉換為正確的json格式:value = value.replace("=", ":");String [] arrayStr=value.split(",");JsonObjectBuilder builder = Json.createObjectBuilder();String key = null;for (String s: arrayStr){    if(key == null) {        key = s;    } else {        builder.add(key, s);        key = null;    }}JsonObject val = builder.build();以下是我擁有的內容以及我想如何表達它:[{Locale=en, Address={House=138, Street=Whitefield Road, CityDistrict=Bangalore, City=Bangalore, District=Bangalore, RegionCode=KA, Region=Whitefield, CountryCode=IND, Country=India, PostalCode=560066}}, {Locale=de, Address={House=138, Street=Whitefield Road, CityDistrict=Bangalore, City=Bangalore, District=Bangalore, RegionCode=KA, Region=Whitefield, CountryCode=IND, Country=India, PostalCode=560066}}][{"Locale":"en","Address":{"House":"138","Street":"Whitefield Road","CityDistrict":"Bangalore","City":"Bangalore","District":"Bangalore","RegionCode":"KA","Region":"Whitefield","CountryCode":"IND","Country":"India","PostalCode":"560066"}},{"Locale":"de","Address":{"House":"138","Street":"Whitefield Road","CityDistrict":"Bangalore","City":"Bangalore","District":"Bangalore","RegionCode":"KA","Region":"Whitefield","CountryCode":"IND","Country":"India","PostalCode":"560066"}}]
查看完整描述

1 回答

?
牛魔王的故事

TA貢獻1830條經(jīng)驗 獲得超3個贊

String value = arrayObject.get(VALUE).toString(); 
JSONArray array = new JSONArray(value);


查看完整回答
反對 回復 2022-09-07
  • 1 回答
  • 0 關注
  • 136 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號