Below is the json data that I have which contains array of states. The size of array is always 2, but the order of elements of the array is not fixed. The array elements values can be null. The sample data is as shown below:
{
"status": "SUCCESS",
"status_message": "Susscessfully queried details.",
"total_records": 2,
"m_details":
[
{
"p_id": 1023,
"pname": "india",
"states":
[
{
"state": "karnataka",
"capital": "bangalore"
},
{
"state": null,
"capital": null,
}
]
},
{
"p_id": 1023,
"pname": "india",
"states":
[
{
"state": null,
"capital": null
},
{
"state": "Tamilnadu",
"capital": "chennai"
}
]
}
]
}
My questions:
- How to convert the null values to some default text say "-".
- How can I sort all the states in asc or desc order.