Hello,
I have a problems with date values when i call hb_jsonencode and hb_jsondecode
After call hb_jsondecode date value is a number value.
Can anyone test this code?
Function Main()
Local cJson,xVar
SetMode( 24 , 80 )
SET DATE BRITISH
Set(_SET_DATEFORMAT,"DD/MM/YYYY")
cJson:= hb_jsonencode( {"DATE"=> Stod("20210401") } )
Hb_jsondecode( cJson , @xVar )
? xVar["DATE"]
Return
Thank you.
Hello,
I have a problems with date values when i call hb_jsonencode and hb_jsondecode
After call hb_jsondecode date value is a number value.
Can anyone test this code?
Function Main()
Local cJson,xVar
SetMode( 24 , 80 )
SET DATE BRITISH
Set(_SET_DATEFORMAT,"DD/MM/YYYY")
cJson:= hb_jsonencode( {"DATE"=> Stod("20210401") } )
Hb_jsondecode( cJson , @xVar )
? xVar["DATE"]
Return
Thank you.
Hello,
I have a problems with date values when i call hb_jsonencode and hb_jsondecode
After call hb_jsondecode date value is a number value.
Can anyone test this code?
Function Main()
Local cJson,xVar
SetMode( 24 , 80 )
SET DATE BRITISH
Set(_SET_DATEFORMAT,"DD/MM/YYYY")
cJson:= hb_jsonencode( {"DATE"=> Stod("20210401") } )
Hb_jsondecode( cJson , @xVar )
? xVar["DATE"]
Return
Thank you.
On Tuesday, September 28, 2021 at 4:07:29 PM UTC+3, pereco...@gmail.com wrote:
Hello,
I have a problems with date values when i call hb_jsonencode and hb_jsondecode
After call hb_jsondecode date value is a number value.
Can anyone test this code?
Function Main()
Local cJson,xVar
SetMode( 24 , 80 )
SET DATE BRITISH
Set(_SET_DATEFORMAT,"DD/MM/YYYY")
cJson:= hb_jsonencode( {"DATE"=> Stod("20210401") } )
Hb_jsondecode( cJson , @xVar )
? xVar["DATE"]
Return
Thank you.In JavaScript and in JSON there is no "date" primitive data type - you need to convert your date value into string.
El dia dimarts, 28 de setembre de 2021 a les 22:04:19 UTC+2, Ella Stern va escriure:
On Tuesday, September 28, 2021 at 4:07:29 PM UTC+3, pereco...@gmail.com wrote:
Hello,
I have a problems with date values when i call hb_jsonencode and hb_jsondecode
After call hb_jsondecode date value is a number value.
Can anyone test this code?
Function Main()
Local cJson,xVar
SetMode( 24 , 80 )
SET DATE BRITISH
Set(_SET_DATEFORMAT,"DD/MM/YYYY")
cJson:= hb_jsonencode( {"DATE"=> Stod("20210401") } )
Hb_jsondecode( cJson , @xVar )
? xVar["DATE"]
Return
Good morning,Thank you.In JavaScript and in JSON there is no "date" primitive data type - you need to convert your date value into string.
I found the problem.
I'm compile with xhb.com.
In file "hbjson.c" at function "_hb_jsonEncode", i changed the order of " else if( HB_IS_DATE( pValue ) )" before of " else if( HB_IS_NUMERIC( pValue ) )" and work fine.
It's strange, but works.
Can you make this changes to repository?
Thank you
Pere.
On Wednesday, September 29, 2021 at 12:13:02 AM UTC-6, pereco...@gmail.com wrote:
El dia dimarts, 28 de setembre de 2021 a les 22:04:19 UTC+2, Ella Stern va escriure:
On Tuesday, September 28, 2021 at 4:07:29 PM UTC+3, pereco...@gmail.com wrote:
Hello,
I have a problems with date values when i call hb_jsonencode and hb_jsondecode
After call hb_jsondecode date value is a number value.
Can anyone test this code?
Function Main()
Local cJson,xVar
SetMode( 24 , 80 )
SET DATE BRITISH
Set(_SET_DATEFORMAT,"DD/MM/YYYY")
cJson:= hb_jsonencode( {"DATE"=> Stod("20210401") } )
Hb_jsondecode( cJson , @xVar )
? xVar["DATE"]
Return
Good morning,Thank you.In JavaScript and in JSON there is no "date" primitive data type - you need to convert your date value into string.
I found the problem.
I'm compile with xhb.com.
In file "hbjson.c" at function "_hb_jsonEncode", i changed the order of " else if( HB_IS_DATE( pValue ) )" before of " else if( HB_IS_NUMERIC( pValue ) )" and work fine.
It's strange, but works.
Can you make this changes to repository?
Thank youHi Pere Cordonet:
Pere.
I confirm that the change you made to hbjson.c corrects the error-- so that the return is the character string "20210401" Good detective work !
However, I have no idea *why* it works ?? !!
Because in this particular section of the code, the Harbour version is identical to the original code in xHarbour. !
I don't understand how the (pValue) can be both NUMERIC *and* DATE at the same time.
What is happening here ???
-Mel Smith
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 349 |
Nodes: | 16 (2 / 14) |
Uptime: | 103:28:30 |
Calls: | 7,610 |
Calls today: | 1 |
Files: | 12,786 |
Messages: | 5,682,501 |