Parsing invalid json field

I’m trying to parse a response of OpenStreetMaps API:

{
            "type": "way",
            "id": 71571983,
            "nodes": [
                851336292,
                851336294,
                2477095657,
                851336312,
                851336315,
                851336317,
                851336319,
                851336322,
                2477095888,
                851336324,
                2477095904,
                2477095903,
                851336326,
                5335992481,
                851336292
            ],
            "tags": {
                "addr:housename": "Universidade Católica Portuguesa Campus de Lisboa",
                "addr:postcode": "1600",
                "alt_name": "UCP lisboa",
                "amenity": "university",
                "int_name": "Catholic University of Portugal",
                "name": "Universidade Católica Portuguesa Lisboa",
                "website": "www.ucp.pt",
                "wikidata": "Q970751",
                "wikipedia": "pt:Universidade Católica Portuguesa"
            }
        },

How can i parse fields like “addr:housename” and “addr:postcode”?
All the solutions i found tell me to use json libraries i can’t use with Unity.

Thanks in advance!

There are multiple free JSON utilities on the Asset Store. Which of them have you tried, and what was the issue you had with them? Your example looks straightforward enough, and should not pose any issues for most of them.

-ch

1 Like

I solved the problem with a free library from asset store: JSON .NET For Unity | Input Management | Unity Asset Store

I used the following in the code:

 [JsonProperty("addr:postcode")]
    public string addr_postcode;

Here is the all code:

[Serializable]
public class Tag
{
    public string amenity;
    public string building;
    public string name;
    public string alt_name;
    public string old_name;
    public string short_name;
    public string official_name;
    public string denomination;
    public string description;
    public string phone;
    public string email;
    public string fax;
    public string telephone;
    public string website;
    public string historic;
    public string castle_type;
    public string cuisine;
    public string takeaway;
    public string internet_access;
    public string outdoor_seating;
    public string smoking;
    public string wheelchair;
    public string opening_hours;
    public string layer;
    public string shelter_type;
    public string religion;
    public string tourism;
    public string parking;
    public string access;
    public string fee;
    public string park_ride;
    public string supervised;
    public string surface;
    public string landuse;
    public string shop;
    public string barrier;
    public string area;
    public string capacity;
    public string start_date;
    public string leisure;
    public string cargo;
    public string ownership;
    public string social_facility;
    public string emergency;
    public string note;
    public string diplomatic;
    public string country;

    [JsonProperty("addr:postcode")]
    public string addr_postcode;

    public string source;
    public string wikidata;
    public string wikipedia;
}

I hope it helps other person.

Thanks for your reply!
The problem was that i tried to import a nuget package instead of using an asset store solution.