[英]How i can sort string in c#?
I'm developing an Android application with Visual Studio / Xamarin I have to sort a string that contains a JSON
object that is like this: 我正在使用Visual Studio / Xamarin开发一个Android应用程序我必须对包含
JSON
对象的字符串进行排序,如下所示:
[{"Entities":{"en-US":{"Items":[{"Resources":[], "Id":"1234567","Name":"Filter","ContentBody":"","Cover":"","Language":,"Action":0}],"Id":"1234567","Name":"04 SOMETHING","ContentBody":"","Cover":"","Language":"en-US","Action":0},"it-IT":{"Items":[{"Resources":[], "Id":"1234567","Name":"Filtro","ContentBody":"","Cover":"","Language":null,"Action":0}]
This is a small part of my json, I need to sort JSON by name ("04 SOMETHING") this "name" is composed by a numeric ID and a String (i need to sort by this id). 这是我的json的一小部分,我需要按名称排序JSON(“04 SOMETHING”)这个“名称”由数字ID和字符串组成(我需要按此id排序)。
How i can do this ? 我怎么能这样做?
You can use this code : 您可以使用此代码:
JArray sorted = new JArray(jsonResult["Items"].OrderBy(obj => obj["Id"]));
jsonResult["Items"] = sorted;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.