reading variable from one (special) class

Since CreateFromJSON needs a class without Monobehaviour, I have 2 classes in my GO:

    [System.Serializable]
    publicclass nomre
    {
    publicstaticint age;
    publicstatic nomre CreateFromJSON(string jsonString)
    {
    returnJsonUtility.FromJson<nomre>(jsonString);
    }}

and below

    publicclasscaller:MonoBehaviour{
    ...
    string jsonity = www.downloadHandler.text;
    Debug.Log("www."+ jsonity);
    nomre.CreateFromJSON(jsonity);
    Debug.Log("age: "+ nomre.age);

The debug(www) shows that the JSON object is correct and includes “age” : 20 but the debug(nomre.age) shows 0. There’s no warning or error in my code, I just don’t get it. Thanks for your help guru!

How does the JSON look, and what does the first debug statement return?

EDIT: It looks like you’re running CreateFromJSON(), and throwing the result away. You’re not saving it anywhere, so you never set age to anything, so it’s the default int value of 0.

Thanks Boz0r
JSON as Debug return is {“age” : 20} from a UnityWebRequest
Reading Unity - Scripting API: JsonUtility.FromJson I understand that returnJsonUtility.FromJson(jsonString) populates all variables (age here).
I think you’re pointing me in the right direction but can’t get how to populate nomre variables. Can you write a quick example?

public class Caller : MonoBehaviour
{
    public void GetJson()
    {
        string jsonity = www.downloadHandler.text;
        Debug.Log("www."+ jsonity);
        // You need to add the result from CreateFromJson to a variable, as you don't set it in the originl object.
        var result = nomre.CreateFromJSON(jsonity);
        Debug.Log("age: "+ result.age);
    }
}

It doesn’t work because it’s a static.

JsonUtility.FromJsonOverwrite(jsonString, this); works from within the Monobehaviour class … 6 hours lost. My stupid bad.
c# - Saving/loading data in Unity - Stack Overflow is what is missing in Unity doc.

I missed that your field was static, then indeed it wouldn’t work (though FromJsonOverwrite also shouldn’t work.

Also, what part exactly is not documented according to you? I see everything said in your link documented in Unity docs.