From 2209e8118b1dfaa09ca0e8f37a1b83dd3f0751ca Mon Sep 17 00:00:00 2001 From: BStraw Date: Sun, 28 Feb 2021 16:38:41 -0600 Subject: [PATCH] Properly parse negative values Update PATINDEX search for start of value to include a minus sign. --- ParseJSON.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ParseJSON.sql b/ParseJSON.sql index e611d2c..7c15577 100644 --- a/ParseJSON.sql +++ b/ParseJSON.sql @@ -11,7 +11,7 @@ Summary: > Then, the routine iteratively finds the next structure that has no structure Contained within it, (and is, by definition the leaf structure), and parses it, - replacing it with an object token of the form ‘@Objectxxx‘, or ‘@arrayxxx‘, + replacing it with an object token of the form ‘@Objectxxx‘, or ‘@arrayxxx‘, where xxx is the object id assigned to it. The values, or name/value pairs are retrieved from the string table and stored in the hierarchy table. G radually, the JSON document is eaten until there is just a single root @@ -223,7 +223,7 @@ Returns: > --HR Engineering notation bugfix end SELECT @end=PATINDEX('%[A-Za-z0-9@+.e][^A-Za-z0-9@+.e]%', @contents+' ' collate SQL_Latin1_General_CP850_Bin) + 1 SELECT - @start=PATINDEX('%[^A-Za-z0-9@+.e][A-Za-z0-9@+.e]%', ' '+@contents collate SQL_Latin1_General_CP850_Bin) + @start=PATINDEX('%[^A-Za-z0-9@+.e][A-Za-z0-9@+.e][\-]%', ' '+@contents collate SQL_Latin1_General_CP850_Bin) --select @start,@end, LEN(@contents+'|'), @contents SELECT @Value=RTRIM(SUBSTRING(@contents, @start, @End-@Start)), @@ -273,4 +273,4 @@ Returns: > -- RETURN END -GO \ No newline at end of file +GO