implement classes in sbu.cs.parser.json package.
- extract good methods
- declare classes where is needed
- all json that you need to parse have only 5 possible value types
- String
- number
- boolean (true or false)
- null
- array
- all json that you need to parse have these rules
- keys are in double quote (" ")
- between key and value there is :
- between each key/value pair there is a comma (,)
- a json object will always start with { and end with }
-
implement function getValue which return the value of a key which is not necessarily a String. it can be int, null, boolean or another Json object. for this you probably need to declare classes for values.
-
write a json parser which can parse json that have a key mapped to another json.
implement classes in sbu.cs.parser.html package.
- extract good methods
- declare classes where is needed
- in all html Strings given to parse these rules are considered.
- all tags that start will end eventually. there is no tag that opens and never close.
- tags may have attributes and all attributes are in key/value pairs
- implement function toHTMLString that gets a Dom object (Node root) and return a String that is the html representation of dom object (opposite of parse)
String str = " salam ";
System.out.println(str.trim()); // will print 'salam'
read about this function. you may need what it does in this series.