Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JArry does not accept list patterns #2992

Open
zms9110750 opened this issue Oct 25, 2024 · 1 comment
Open

JArry does not accept list patterns #2992

zms9110750 opened this issue Oct 25, 2024 · 1 comment

Comments

@zms9110750
Copy link

Source/destination types

if (json["entries"] is JArray and [var first, ..])
{
	Console.WriteLine(first["message"]);
} 

Source/destination JSON

{
  "return": {
    "status": 200,
    "message": "Approved"
  },
  "entries": [
    {
      "messageId": 1466447495,
      "message": "Your verification code: 23298",
      "status": 5,
      "statusText": "Sent",
      "sender": "1000551451",
      "receptor": "918181818181818181",
      "date": 1701615164
    }
  ]
}

Expected behavior

Running successfully

Actual behavior

Unhandled exception. System.ArgumentException: Accessed JArray values with invalid key value: 0. Int32 array index expected.

Steps to reproduce

// Your calls to Newtonsoft.Json here

dotnet/csharplang#8535 (reply in thread)

@zms9110750
Copy link
Author

and , i think can add this int.CreateChecked()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant