Skip to content

Commit 05e7e41

Browse files
committed
readme 3
1 parent 6b86a21 commit 05e7e41

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

README.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#Original [package org.json] Douglas Crockford
33

44
The key changes are:
5-
##JSONObject is extended from LinkedHashMap ##
5+
##JSONObject is extended from LinkedHashMap
66

77
* Ensures order of elements
88
* Enables the normal HashMap methods to be available although most of them were overridden in earlier implementation like keys() and keySet()
@@ -14,18 +14,19 @@ The key changes are:
1414
> This is because in JDK 7 getDeclaredMethods() does not retrieve the methods in order it is random and can vary from time to time. A bug was logged for jdk but was rejected as wont fix.
1515
> In JDK6 and lower versions the order is maintained however this is a feature not mentioned in specifications of jdk.
1616
17-
##JSONArray extends from ArrayList##
17+
##JSONArray extends from ArrayList
1818
* This in combination with JSONObjects extends from LinkedHashMap enables the whole library to be usable in a generic way where other libraries which uses model data in any combination of Map<String, Object> and List<Object> for example Map<String,List<Object>>.
1919

2020

21-
##XML to JSON Serialization##
21+
##XML to JSON Serialization
2222
* Attributes are marked with a '@' prepended to the key
2323
* Content element is marked with a '#' prepended to the key
2424
* Since the json keeps order of the original xml elements it can be deserialized back to same xml.
2525

26+
#### Earlier version of JSON below refers to release version 20090211 or before.
2627

2728
An xml of format
28-
```xml
29+
```java
2930
<root><person fname="samarjit" lname="samanta" >normal text</person></root>
3031

3132
//will serialize to
@@ -34,10 +35,10 @@ An xml of format
3435
//In earlier version it used to serialize to
3536
{"root":{"person":{"fname":"samarjit","lname":"samanta","content":"normal text"}}}
3637
```
37-
##JSON to XML Serialization##
38+
##JSON to XML Serialization
3839

3940
Since we have the attribute marked in the json, we can create back the exact xml
40-
```xml
41+
```java
4142
//This version if input json is
4243
{"root":{"person":{"@fname":"samarjit","@lname":"samanta","#content":"normal text"}}}
4344

@@ -52,7 +53,7 @@ Since we have the attribute marked in the json, we can create back the exact xml
5253
5354
Example of libraries that uses model as combination of Map<String,Object> and List<Object> and arbitrary java beans.
5455

55-
### Freemarker ###
56+
### Freemarker
5657
```java
5758
String templateExpression = "Hi ${ddd} hello ${ar[0]} your home is ${USER_HOME}";
5859

@@ -72,16 +73,16 @@ Example of libraries that uses model as combination of Map<String,Object> and Li
7273
System.out.println(ret);
7374
```
7475
Result
75-
76+
```java
7677
//This version produces
7778
Hi jsss hello jhaldia your home is C:/Users/Samarjit
7879

7980
//Earlier version json:
8081
Hi jsss hello [ your home is C:/Users/Samarjit
81-
82+
```
8283
8384
84-
### Ognl ###
85+
### Ognl
8586
```java
8687
JSONObject jobj1 = new JSONObject();
8788
jobj1.put("ddd","jsss");
@@ -102,5 +103,5 @@ This version produces
102103
```
103104

104105

105-
Please refer to the original README for other functions.
106+
> Please refer to the original README for other functions.
106107

0 commit comments

Comments
 (0)