azuredatastudio icon indicating copy to clipboard operation
azuredatastudio copied to clipboard

JSON not recognized in any row if at least one of them is NULL

Open IAmHopp opened this issue 6 years ago • 5 comments

Issue Type: Bug

Hi guys,

So, Operations Studio is able to recognize JSON in the results view. It highlights it and, upon clicking, opens a new tab with the JSON expanded, which is extremely useful if the value is a long string.

However, this only works if all the rows have the column in question filled with valid JSON. If at least one row has NULL as its value, none of the rows will have the column identified and expandable as JSON.

A simple query returning two rows where one of them has a column with a NULL value and the other has a valid JSON is enough to reproduce this.

SQL Operations Studio version: sqlops 0.31.4 (e026ab85a72c190cc4ccc834503aa9fe36dd6407, 2018-07-18T02:14:21.826Z) OS version: Windows_NT x64 10.0.17134

System Info
Item Value
CPUs Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz (8 x 3600)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
rasterization: unavailable_software
video_decode: enabled
video_encode: enabled
vpx_decode: enabled
webgl: enabled
webgl2: enabled
Memory (System) 15.88GB (5.94GB free)
Process Argv C:\Program Files\SQL Operations Studio\sqlops.exe
Screen Reader no
VM 0%
Extensions (1)
Extension Author (truncated) Version
profiler Mic 0.1.2

IAmHopp avatar Aug 17 '18 17:08 IAmHopp

Also @kburtram, as I mentioned at the time of reporting, SQL Operations Studio, at least at that version, used to highlight JSON cells in the results view. Is this no longer the case? Neither Azure Data Studio build I've used does it.

If this is intended and permanent behavior, was there an issue requesting this or something?

Thanks in advance.

IAmHopp avatar Oct 18 '18 16:10 IAmHopp

@IAmHopp It is a bugged we have tracked in other issues we are working on.

anthonydresser avatar Oct 19 '18 17:10 anthonydresser

This also appears when one of the rows contains an empty string value, and when one of the rows contains non-json formatted data.

By the way: is issue only seems to appear when the first row in the resultset is non-json. If the first row is json-formatted, all rows are treated as json.

matthijsvogt avatar Feb 21 '20 14:02 matthijsvogt

By the way: is issue only seems to appear when the first row in the resultset is non-json. If the first row is json-formatted, all rows are treated as json.

Seems like an improvement, then. From what I remember, the issue with NULL would happen even if the first row was JSON.

In any case, this should really be looked at at this point.

IAmHopp avatar Feb 21 '20 14:02 IAmHopp

it can also happen for just some rows and not others. If the json string has crlf or lf then ADS doesn't allow you to click it to open. I can create a seperate item if necessary as it isn't quite the same as the title

repro with this

select '[{}]' -- opens as json
union all select concat('[{', char(13), char(10), '}]') -- can't open as json

you need to

replace(replace(JsonString, char(10), ''), char(13), '')

to fix it

o-o00o-o avatar Sep 14 '22 19:09 o-o00o-o