Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Parsing json data to property?

Discussion in 'Scripting' started by GemShards, Feb 3, 2019.

  1. GemShards

    GemShards

    Joined:
    May 8, 2018
    Posts:
    10
    Hello,

    I recently started converting my variable fields to properties, but hit an issue with a class that is used to parse a json.

    I converted them to the following:

    public string ability{get; set;}


    and now on parsing the json, they don't come through. The json has them formatted as such:

    "ability": "Firepunch",

    etc.

    Is there a way to parse from json into a property, or is it not worth bothering?
     
  2. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,637
    Hi @GemShards

    To parse JSON data with what? Using built-in JsonUtility or something else?

    JsonUtility doesn't support anything but fields AFAIK.
     
  3. GemShards

    GemShards

    Joined:
    May 8, 2018
    Posts:
    10
    Ah, that'll explain it. Thanks!
     
  4. odoluca

    odoluca

    Joined:
    Nov 5, 2014
    Posts:
    28
    you can use JSON .NET. it supports both properties and privates.