MizLucid
MizLucid

Reputation: 241

How to sort json to text?

How can i sort a string from JsonText string to Sorted strings?

From

{
"A": "Command",
"B": [],
"C": "leaderboard.leaderboard",
"D": 3,
"E": "get_leaderboard_infos"
}

to

A : Command
D : 3
E : get_leaderboard_infos

Upvotes: 0

Views: 196

Answers (1)

Ted
Ted

Reputation: 3260

First use JSON.Net to parse the JSON text into objects. Once they are objects, you can sort or filter the objects in a list based on their values.

In order to "prune" the objects, meaning get rid of unwanted properties and values, simply create a different object that only has the properties you like, and copy the values from the JSON.Net output to your new objects, and then serialize your new objects into a new JSON string.

Upvotes: 4

Related Questions