Skip to content

Commit

Permalink
Made OPENJSON handling of scalar values consistent with SQL Server
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkMpn committed Nov 17, 2023
1 parent 9670131 commit 7d52cc7
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions MarkMpn.Sql4Cds.Engine/ExecutionPlan/OpenJsonNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,11 @@ protected override IEnumerable<Entity> ExecuteInternal(NodeExecutionContext cont
{
jpath = new JsonPath(path);
jsonDoc = JsonDocument.Parse(json.Value).RootElement;

// Don't allow JSON scalar values, only objects or arrays
if (jsonDoc.ValueKind != JsonValueKind.Object && jsonDoc.ValueKind != JsonValueKind.Array)
throw new JsonException("JSON text is not properly formatted. Object or array is required");

jtoken = jpath.Evaluate(jsonDoc);
}
catch (JsonException ex)
Expand Down

0 comments on commit 7d52cc7

Please sign in to comment.