Skip to content

The use of null or Nothing in JSON literals sometimes cause error BC30521 #16

Open

Description

@Nukepayload2

Summary

I'm trying to initialize a variable with the JSON literal syntax. When I copy a JSON snippet to VB code, null objects in JSON have compilation errors.

Steps to reproduce

Use the following JSON to initialize a variable:

{
  "columns": {
    "A": {
      "rows": {
        "1": {
          "value": 1
        },
        "2": {
          "value": 1
        },
        null,
        "4": {
          "value": 1
        }
      }
    }
  }
}

Expected behavior

No compilation errors. The type of null is DEFAULT_JSON_OBJECT_TYPE.

Actual behavior

Error BC30521
image

Workaround

Use an uninitialized JObject or JsonObject to replace null objects.

JsonConstants.vb

Imports Newtonsoft.Json.Linq

Module JsonConstants
    Friend vbNullJsonObject As JObject
End Module

image

Activity

  1. AnthonyDGreen commented on Aug 29, 2022

    @AnthonyDGreen
    Contributor

    Thanks for the bug report. I'll look into this and try to put a fix out soon. And thanks for trying out the mod and for writing such a detailed blog post about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions