1

I am building a xamarin forms app and am currently working on a ListView pulled from a Wordpress site's rest api. I attempted to use Json2Csharp to generate properties and classes, but json to csharp is telling me there are invalid names in json objects I would need to use, like the featured image URL. Is there something I don't know about naming properties?

Also, has anyone built a xamarin or xamarin forms app with wordpress as a backend. I have been unable to find any good examples of such work and find the implementation confusing. For one, wp-json gives you html, not plain text. So an endpoint needs to be added or you need to parse html.

Anyway, the Json and Class:

Json
  "wp:featuredmedia": [
    {
      "embeddable": true,
      "href": "https://www.somesite.com/wp-json/wp/v2/media/2453"
    }
  ],
  "wp:attachment": [
    {
      "href": "https://www.somesite.com/wp-json/wp/v2/media?parent=2452"
    }
  ],

C# Class

public class Links
    {
    public List<Self> self { get; set; }
    public List<Collection> collection { get; set; }
    public List<About> about { get; set; }
    public List<Author> author { get; set; }
    public List<Reply> replies { get; set; }
    public List<VersionHistory> __invalid_name__version-history { get; set; }
    public List<WpFeaturedmedia> __invalid_name__wp:featuredmedia { get; set; }
    public List<WpAttachment> __invalid_name__wp:attachment { get; set; }
    public List<WpTerm> __invalid_name__wp:term { get; set; }
    public List<Cury> curies { get; set; }
    }
PeterG
  • 125
  • 2
  • 8
  • The first question in your question is a duplicate of [How to Deserialize an JSON object with invalid field name in it](https://stackoverflow.com/q/12215181/3744182). The second part looks too general for stackoverflow. If you can make it more concrete, you can ask another question. – dbc Mar 24 '17 at 19:57
  • That works, thank you. – PeterG Mar 24 '17 at 20:05

0 Answers0