我被困在这个问题上很长时间了。任何帮助将不胜感激。 在我的应用程序中,我使用 android volley 来获取 json 响应。 我从带有键值对的网址收到如下响应:
description: "This Collection channels a contemporary flavour to the flowy top. The cape-styled sleeves add a heroine spin to the everyday ensemble and all you need to do is to team this with your favourite basic for a polished look. - Polyblend - Round neckline - Long sleeves - Slip-on style - Regular fit - Unlined Colour: Navy Care label: Hand wash only at maximum temperature of 40 degree celcius Composition: 95% Polyester, 5% Spandex Model's body measurements: Height: 175cm Bust: 32"/80cm Waist: 23"/59cm Hips: 35"/89cm Size of model's garment: S Measurements: Shoulder Length x Sleeve Opening x Bust circumference x Waist circumference x Hem circumference x Length - XS (36.5cm x 26.5cm x 83cm x 87cm x 99cm x 58.5cm) - S (37cm x 26cm x 87cm x 92cm x 103cm x 58.5cm) Production country: ",
我想分割这个字符串并显示如下:
该系列为飘逸的上衣注入(inject)了现代气息。斗篷风格的袖子为日常装扮增添了女主角的气质,您所需要做的就是将其与您最喜欢的基本款搭配,打造优雅的外观。
- 聚酯混合物
- 圆领
- 长袖
- 一脚蹬款式
- 常规版型
无内衬
颜色:海军蓝
护理标签:只能在最高 40 摄氏度的温度下手洗
成分:95% 涤纶,5% 氨纶
尺寸:肩长 x 袖口 x 胸围 x 腰围 x 下摆围 x 衣长
- XS(36.5 厘米 x 26.5 厘米 x 83 厘米 x 87 厘米 x 99 厘米 x 58.5 厘米)
- 小号(37厘米 x 26厘米 x 87厘米 x 92厘米 x 103厘米 x 58.5厘米)
最佳答案
尝试在每个字符串 "- "
以及 "key: value"
模式之前添加新行。
在示例中,“key: value”
模式中的所有键均以大写字母开头,因此仅考虑以大写字母开头的键。
虽然这适用于此示例,但包含 "- "
或 ": "
的说明会添加不必要的换行符或项目符号。我相信像这样的不完美解决方案必须足以满足所提供的数据。
关于java - 分割从 Json 响应收到的字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32535541/