I am attempting to use the API from a 3rd party website to retrieve information, unfortunately it provides way more information that I need. from my understanding of the java deserializer, the class needs to exactly match the json string to parse properly. I was wondering if there was a way to retrieve only the values I am interested in without having to do a ton of string splitting.
example:
//my class
class message
{
public string id { get; set; }
public string author { get; set; }
public string body { get; set; }
}
// json string
{
"body": "this is test 2",
"was_comment": false,
"first_message": null,
"name": "name",
"first_message_name": null,
"created": 1402707862.0,
"dest": "recipiant",
"author": "author",
"parent_id": null,
"context": "",
"replies": "",
"new": true,
"id": "das9deh",
"subject": "test2"
}
as you can see there is a substantial amount of information in the json string that I do not need for my purposes, so I was wondering if there is an efficient way to simply pull out the id,author, and body values directly to my class.
This is why my question is different:
I get a large json string from a 3rd party that I want to deserialize. my question is, how to deserialize without having a class that exactly matches the json string as I only need selected values.
in the proposed solution is the opposite of the answer I'm looking for