FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
JSON-java/src/main/java/org/json/Property.java at master · rbiddulph/JSON-java · GitHub
rbiddulph
/
JSON-java
Public
forked from
stleary/JSON-java
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
JSON-java
/
src
/
main
/
java
/
org
/
json
/
Property.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
55 lines (51 loc) · 1.83 KB
Breadcrumbs
JSON-java
/
src
/
main
/
java
/
org
/
json
/
Property.java
Copy path
File metadata and controls
55 lines (51 loc) · 1.83 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
package
org
.
json
;
/*
Public Domain.
*/
import
java
.
util
.
Enumeration
;
import
java
.
util
.
Properties
;
/**
* Converts a Property file data into JSONObject and back.
* @author JSON.org
* @version 2015-05-05
*/
public
class
Property
{
/**
* Converts a property file object into a JSONObject. The property file object is a table of name value pairs.
* @param properties java.util.Properties
* @return JSONObject
* @throws JSONException if a called function has an error
*/
public
static
JSONObject
toJSONObject
(
java
.
util
.
Properties
properties
)
throws
JSONException
{
// can't use the new constructor for Android support
// JSONObject jo = new JSONObject(properties == null ? 0 : properties.size());
JSONObject
jo
=
new
JSONObject
();
if
(
properties
!=
null
&& !
properties
.
isEmpty
()) {
Enumeration
<?>
enumProperties
=
properties
.
propertyNames
();
while
(
enumProperties
.
hasMoreElements
()) {
String
name
= (
String
)
enumProperties
.
nextElement
();
jo
.
put
(
name
,
properties
.
getProperty
(
name
));
}
}
return
jo
;
}
/**
* Converts the JSONObject into a property file object.
* @param jo JSONObject
* @return java.util.Properties
* @throws JSONException if a called function has an error
*/
public
static
Properties
toProperties
(
JSONObject
jo
)
throws
JSONException
{
Properties
properties
=
new
Properties
();
if
(
jo
!=
null
) {
// Don't use the new entrySet API to maintain Android support
for
(
final
String
key
:
jo
.
keySet
()) {
Object
value
=
jo
.
opt
(
key
);
if
(!
JSONObject
.
NULL
.
equals
(
value
)) {
properties
.
put
(
key
,
value
.
toString
());
}
}
}
return
properties
;
}
}
Back
|
FazBrowse Home
|
New Git URL