Skip to content
This repository was archived by the owner on Oct 6, 2023. It is now read-only.
This repository was archived by the owner on Oct 6, 2023. It is now read-only.

Bug: 'JObject' does not contain a definition for 'ContainsKey' #80

Description

@ghostravenstorm

Expected behavior

Calling ContainsKey on a JObject should return true if the JObject has the key.
https://www.newtonsoft.com/json/help/html/M_Newtonsoft_Json_Linq_JObject_ContainsKey.htm

Actual behavior

Unity complier doesn't recognize JObject.ContainsKey(string)

Steps to reproduce

  • New project
  • Import jillejr.newtonsoft.json-for-unity via UPM
  • Add following script to scene:
public class JsonTest : MonoBehaviour {

   void Start () {
      string jsonstr = "{\"name\":\"foo\"}";
      JObject jobject = JObject.Parse(jsonstr);
      bool containsKey = jobject.ContainsKey("name");
   }
}
  • Observe the error in the console

Details

Windows Unity Editor

Newtonsoft.Json-for-Unity package version 2.0.1

Unity 2019.4.18f1

Checklist

  • Shutdown Unity, deleted the /Library folder, opened project again in Unity, and problem still remains.
  • Checked to be using latest version of the package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions