@@ -111,7 +111,7 @@ package JSON is
111111 function jsonGetRealArray(JSONContext : T_JSON; Path : string ) return real_vector ;
112112 function jsonGetRealArray(JSONContext : T_JSON; Path : string ; Len : positive ) return real_vector ;
113113
114- function jsonGetNumberArrayLength (JSONContext : T_JSON; Path : string ) return natural ;
114+ function jsonGetArrayLength (JSONContext : T_JSON; Path : string ; IsType: character ) return natural ;
115115 function jsonIsBoolean(JSONContext : T_JSON; Path : STRING ) return BOOLEAN ;
116116 function jsonIsNull(JSONContext : T_JSON; Path : STRING ) return BOOLEAN ;
117117 function jsonIsString(JSONContext : T_JSON; Path : STRING ) return BOOLEAN ;
@@ -1629,12 +1629,8 @@ package body JSON is
16291629
16301630 -- function to get a boolean_vector from the compressed content extracted from a JSON input
16311631 function jsonGetBooleanArray(JSONContext : T_JSON; Path : string ) return boolean_vector is
1632- variable len: natural := 0 ;
16331632 begin
1634- while jsonIsBoolean(JSONContext, Path & " /" & to_string(len)) loop
1635- len := len+ 1 ;
1636- end loop ;
1637- return jsonGetBooleanArray(JSONContext, Path, len);
1633+ return jsonGetBooleanArray(JSONContext, Path, jsonGetArrayLength(JSONContext, Path, ' b' ));
16381634 end ;
16391635
16401636 -- function to get a boolean_vector of a fixed length from the compressed content extracted from a JSON input
@@ -1645,13 +1641,12 @@ package body JSON is
16451641 return_value(i) := boolean 'value (jsonGetString(JSONContext, Path & " /" & to_string(i)));
16461642 end loop ;
16471643 return return_value;
1648- end function ;
1644+ end ;
16491645
16501646 -- function to get a integer_vector from the compressed content extracted from a JSON input
16511647 function jsonGetIntegerArray(JSONContext : T_JSON; Path : string ) return integer_vector is
1652- variable len: natural := 0 ;
16531648 begin
1654- return jsonGetIntegerArray(JSONContext, Path, jsonGetNumberArrayLength (JSONContext, Path));
1649+ return jsonGetIntegerArray(JSONContext, Path, jsonGetArrayLength (JSONContext, Path, ' i ' ));
16551650 end ;
16561651
16571652 -- function to get a integer_vector of a fixed length from the compressed content extracted from a JSON input
@@ -1662,13 +1657,12 @@ package body JSON is
16621657 return_value(i) := to_natural_dec(jsonGetString(JSONContext, Path & " /" & to_string(i)));
16631658 end loop ;
16641659 return return_value;
1665- end function ;
1660+ end ;
16661661
16671662 -- function to get a real_vector from the compressed content extracted from a JSON input
16681663 function jsonGetRealArray(JSONContext : T_JSON; Path : string ) return real_vector is
1669- variable len: natural := 0 ;
16701664 begin
1671- return jsonGetRealArray(JSONContext, Path, jsonGetNumberArrayLength (JSONContext, Path));
1665+ return jsonGetRealArray(JSONContext, Path, jsonGetArrayLength (JSONContext, Path, ' r ' ));
16721666 end ;
16731667
16741668 -- function to get a real_vector of a fixed length from the compressed content extracted from a JSON input
@@ -1679,15 +1673,20 @@ package body JSON is
16791673 return_value(i) := real 'value (jsonGetString(JSONContext, Path & " /" & to_string(i)));
16801674 end loop ;
16811675 return return_value;
1682- end function ;
1676+ end ;
16831677
1684- function jsonGetNumberArrayLength (JSONContext : T_JSON; Path : string ) return natural is
1678+ function jsonGetArrayLength (JSONContext : T_JSON; Path : string ; IsType: character ) return natural is
16851679 variable len: natural := 0 ;
1680+ variable val: boolean := true ;
16861681 begin
1687- while jsonIsNumber(JSONContext, Path & " /" & to_string(len)) loop
1682+ while (val) loop
1683+ case IsType is
1684+ when ' b' => val := jsonIsBoolean(JSONContext, Path & " /" & to_string(len));
1685+ when others => val := jsonIsNumber(JSONContext, Path & " /" & to_string(len));
1686+ end case ;
16881687 len := len+ 1 ;
16891688 end loop ;
1690- return len;
1689+ return len- 1 ;
16911690 end ;
16921691
16931692 function jsonIsBoolean(JSONContext : T_JSON; Path : STRING ) return BOOLEAN is
0 commit comments