开发者

Using System.Json to convert C# Arrays and Objects to a JSON string

开发者 https://www.devze.com 2023-02-18 07:56 出处:网络
I am looking at System.Json, but can\'t seem to find methods in here that will allow me to convert a C# array or class instance into a JSON string. I am looking for functionality similar to SBJSON in

I am looking at System.Json, but can't seem to find methods in here that will allow me to convert a C# array or class instance into a JSON string. I am looking for functionality similar to SBJSON in objective-c where, for example, an NSArray can be 开发者_运维百科converted to a JSON string as follows:

NSString *resultArrayString = [json stringWithObject:resultArray allowScalar:YES error:nil];

Staying with this same example, is there an equivalent method in System.Json namespace somewhere that would allow convert a C# string array to a JSON string?


System.Json is a very lightweight reader and writer of the Json format, it does not come with a serializer that would do this for you.

Folks that want more features than the System.Json are using NewtonSoft's open source Json library. It includes many high level features like serialization, JsonDocument and many more features.

0

精彩评论

暂无评论...
验证码 换一张
取 消