You must create a structure representing the JSON keys (in case you know it for sure), and then you can easily deserialize the JSON string in your structure. In my example, I canceled the response description from the Google Cloud Message server:
class templateResponse { public String multicast_id; public String success; public String failure; public String canonical_ids; public Result[] results; public class Result { public String message_id; public String registration_id; public String error; }; }
Incoming JSON was:
"\"multicast_id\":7400896764380883211,\"success\":1,\"failure\":0,\"canonical_ids\":0,\"results\":[{\"message_id\":\"0:1351777805148960%39895cf0f9fd7ecd\"}]}"
So use
templateResponse result = new JavaScriptSerializer().Deserialize<templateResponse>(json);
and you get a deserialized result object
Subtle Fox Nov 02 2018-12-12T00: 00Z
source share