4

I am receiving JSON responses from my sever. Generally it is structuted data. But I am stuck in a particular case where, the data can be of any number of items, each item will have a heading text and some more lines.

a markdown example to show my use-case:

**Heading**
- indented normal text:
* bullet item
* bullet item 2

In which format (HTML/markdown/JSON) should I receive some formatted text from my server? Markdown would be easy for me to create on the server while I dont know how I will parse it in android. JSON would be hard to create on the server but easy to de-serialize in android.

I want to dynamically add this to a ListView, so I want each item to be inflatable to a list_view_item.xml . The entire thing is part of a larger XML. I want it as follows.

list item to be populated

Vedant Agarwala
  • 18,146
  • 4
  • 66
  • 89

2 Answers2

1

JSON for objects, JSONArray for several JSONObjects.

It's not a difficult task to serialize in server! You can use libraries like Jackson etc.

Best option for me.

Juan Aguilar Guisado
  • 1,687
  • 1
  • 12
  • 21
0

Android's TextView naturally supports several html tags for formatting so in case you don't use custom fonts and advanced formatting, html is the best choice.

As for parsing unknown amount of items, you can't get any better than sending a JSON array.

Community
  • 1
  • 1
Lamorak
  • 10,957
  • 9
  • 43
  • 57