blob: 214475fc575d594f9d1188bb32a026b18b4c9c4c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
diff --git src/libcmis/json-utils.cxx src/libcmis/json-utils.cxx
index b537a09..b4e037d 100644
--- src/libcmis/json-utils.cxx
+++ src/libcmis/json-utils.cxx
@@ -213,48 +213,54 @@ Json::Type Json::parseType( )
{
Type type = json_string;
string str = toString( );
- boost::posix_time::ptime time = libcmis::parseDateTime( str );
- if ( !time.is_not_a_date_time( ) )
- type = json_datetime;
- else
+ if ( str.empty( ) )
+ return type;
+ try
{
- Type backupType = type;
- type = json_bool;
- try
- {
- parseBool( str );
- }
- catch (...)
+ boost::posix_time::ptime time = libcmis::parseDateTime( str );
+ if ( !time.is_not_a_date_time( ) )
+ return json_datetime;
+ }
+ catch (...)
+ {
+ // Try other types
+ }
+ Type backupType = type;
+ type = json_bool;
+ try
+ {
+ parseBool( str );
+ }
+ catch (...)
+ {
+ type = backupType;
+ }
+ if ( type != json_bool )
+ {
+ if ( str.find('.') == string::npos )
{
- type = backupType;
+ backupType = type;
+ type = json_int;
+ try
+ {
+ parseInteger( str );
+ }
+ catch(...)
+ {
+ type = backupType;
+ }
}
- if ( type != json_bool )
+ else
{
- if ( str.find('.') == string::npos )
+ backupType = type;
+ type = json_double;
+ try
{
- backupType = type;
- type = json_int;
- try
- {
- parseInteger( str );
- }
- catch(...)
- {
- type = backupType;
- }
+ parseDouble( str );
}
- else
- {
- backupType = type;
- type = json_double;
- try
- {
- parseDouble( str );
- }
- catch(...)
- {
- type = backupType;
- }
+ catch(...)
+ {
+ type = backupType;
}
}
}
|