Aman Arora
Aman Arora

Reputation: 93

Splitting a string received from Json response

I am stuck in this for a very long time.Any help would be appreciated. In my app,I am using android volley to get a json response. I am getting a response from a url with a key-value pair like this:

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: ",

I want to split this string and display it as follows:

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.

Upvotes: 1

Views: 91

Answers (1)

user377628
user377628

Reputation:

Try adding new lines before each string " - ", as well as the "key: value" pattern.

In the example, all keys in the "key: value" pattern started with a capital letter, so only consider a key if it starts with a capital.

While this would work for this example, a description containing " - " or ": " would add unnecessary new line characters or bullets. I believe an imperfect solution like this will have to suffice with the provided data.

Upvotes: 1

Related Questions