cancel
Showing results for 
Search instead for 
Did you mean: 
Warehousing & Analytics
cancel
Showing results for 
Search instead for 
Did you mean: 

Issue while extracting value From Decimal Key is Json

data_guy
New Contributor

Hi Guys,

I have a JSON as the below structure where the key is as decimal.
{ "5.0": { "a": "15.92", "b": 0.0, "c": "15.92", "d": "637.14" }, "0.0": { "a": "15.92", "b": 0.0, "c": "15.92", "d": "637.14" } }
schema_of_json returns the following:

STRUCT<`0.0`: STRUCT<a: STRING, b: DOUBLE, c: STRING, d: STRING>, `5.0`: STRUCT<a: STRING, b: DOUBLE, c: STRING, d: STRING>>

I am facing an issue in extracting values against (a,b,c,d) for 5.0 and 0.0 in Databricks SQL. Following are the methods that I have tried, but still not able to extract value as it is coming NULL.

SELECT 
data,
data:`5.0` as method1,
get_json_object(data, '$.`5.0`') as method2
FROM staging.consumables.test;

 

Can you guys please help?

 

0 REPLIES 0
Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.