The next is formatted inward JSON
["wclass",
{"student":{"name":"Linda Jones","legacySkill":"Access, VB 5.0"}etc..
},
{ "student":{"name":"Adam Davidson","legacySkill":"Cobol, MainFrame"}
},
{"student":{"name":"Charles Boyer","legacySkill":"HTML, XML"}
}]
This is a valid JSON according to RFC 4627.
json_01
However when you lot role this inward SQL Server to hold off at the JSON using the OpenJSON, for example, you lot volition larn this error:
json_00
The argue for this error:
Msg 103, Level 15, State 4, Line 2
The identifier that starts alongside "wclass"...
lies inward the fact that SQL Server string starts alongside a unmarried quote together with thence you lot ask to supply this declaration:
declare @json nvarchar(Max)
set @json=
'["wclass",
{"student":{"name":"Linda Jones","legacySkill":"Access, VB 5.0"}
},
{"student":{"name":"Adam Davidson","legacySkill":"Cobol, MainFrame"}
},
{"student":{"name":"Charles Boyer","legacySkill":"HTML, XML"}
}]'
When you lot produce this the fault goes away equally shown:
json_02
The grapheme count inward @json is too of import equally you lot come across inward this SQL query:
json_03
The response is that RFC 4627 validation requires a string to firstly alongside a double quote("), exactly the SQL Server's JSON validation requires the JSON to laid out alongside a unmarried quote(') equally nosotros saw inward this post.
["wclass",
{"student":{"name":"Linda Jones","legacySkill":"Access, VB 5.0"}etc..
},
{ "student":{"name":"Adam Davidson","legacySkill":"Cobol, MainFrame"}
},
{"student":{"name":"Charles Boyer","legacySkill":"HTML, XML"}
}]
This is a valid JSON according to RFC 4627.
json_01
However when you lot role this inward SQL Server to hold off at the JSON using the OpenJSON, for example, you lot volition larn this error:
json_00
The argue for this error:
Msg 103, Level 15, State 4, Line 2
The identifier that starts alongside "wclass"...
lies inward the fact that SQL Server string starts alongside a unmarried quote together with thence you lot ask to supply this declaration:
declare @json nvarchar(Max)
set @json=
'["wclass",
{"student":{"name":"Linda Jones","legacySkill":"Access, VB 5.0"}
},
{"student":{"name":"Adam Davidson","legacySkill":"Cobol, MainFrame"}
},
{"student":{"name":"Charles Boyer","legacySkill":"HTML, XML"}
}]'
When you lot produce this the fault goes away equally shown:
json_02
The grapheme count inward @json is too of import equally you lot come across inward this SQL query:
json_03
The response is that RFC 4627 validation requires a string to firstly alongside a double quote("), exactly the SQL Server's JSON validation requires the JSON to laid out alongside a unmarried quote(') equally nosotros saw inward this post.
Komentar
Posting Komentar