@@ -113,6 +113,10 @@ module json_module
113113
114114 character (len=* ),parameter :: real_fmt = ' (E30.16E3)' ! format for real numbers
115115 character (len=* ),parameter :: int_fmt = ' (I10)' ! format for integers
116+ character (len=* ),parameter :: null_str = ' null'
117+ character (len=* ),parameter :: true_str = ' true'
118+ character (len=* ),parameter :: false_str = ' false'
119+
116120
117121 ! The types of data:
118122 integer ,parameter ,public :: json_unknown = 0
@@ -2399,7 +2403,7 @@ recursive subroutine json_value_print(this,iunit,indent,need_comma,colon,str)
23992403
24002404 case (json_null)
24012405
2402- call write_it( repeat (space, spaces)// ' null ' , comma= print_comma )
2406+ call write_it( repeat (space, spaces)// null_str , comma= print_comma )
24032407
24042408 case (json_string)
24052409
@@ -2416,9 +2420,9 @@ recursive subroutine json_value_print(this,iunit,indent,need_comma,colon,str)
24162420 case (json_logical)
24172421
24182422 if (this% data % log_value) then
2419- call write_it( repeat (space, spaces)// ' true ' , comma= print_comma )
2423+ call write_it( repeat (space, spaces)// true_str , comma= print_comma )
24202424 else
2421- call write_it( repeat (space, spaces)// ' false ' , comma= print_comma )
2425+ call write_it( repeat (space, spaces)// false_str , comma= print_comma )
24222426 end if
24232427
24242428 case (json_integer)
@@ -3747,23 +3751,24 @@ recursive subroutine parse_value(unit, value)
37473751 end select
37483752 ! end associate
37493753
3750- case (' t ' )
3754+ case (true_str( 1 : 1 ) )
37513755
37523756 ! true
3753- call parse_for_chars(unit, ' rue ' )
3757+ call parse_for_chars(unit, true_str( 2 :) )
37543758 ! allocate class and set value:
37553759 if (.not. exception_thrown) call to_logical(value,.true. )
37563760
3757- case (' f ' )
3761+ case (false_str( 1 : 1 ) )
37583762
37593763 ! false
3760- call parse_for_chars(unit, ' alse ' )
3764+ call parse_for_chars(unit, false_str( 2 :) )
37613765 ! allocate class and set value:
37623766 if (.not. exception_thrown) call to_logical(value,.false. )
37633767
3764- case (' n ' )
3768+ case (null_str( 1 : 1 ) )
37653769
3766- call parse_for_chars(unit, ' ull' )
3770+ ! null
3771+ call parse_for_chars(unit, null_str(2 :))
37673772 if (.not. exception_thrown) call to_null(value) ! allocate class
37683773
37693774 case (' -' , ' 0' : ' 9' )
0 commit comments