First, Java parsing yaml
1. Selection of APIs
Generally divided into two kinds: Jyaml and Snakeyaml. (jyaml:http://download.csdn.net/detail/dgssfgfs/8477109)
Import of 2.Jar Packages
This needless to say, do not own Baidu.
Analysis of 3.yaml
- ......
- Import Org.ho.yaml.Yaml;
- ......
- File F = new file ("Y.yaml");
- FileInputStream fi=new FileInputStream (F.getabsolutepath ());
- HashMap HM = Yaml.loadtype (FI, Hashmap.class);
Yaml.loadtype The first parameter is also a string that is read by Yaml file.
Second, Android parsing Yaml
The choice of 1.API
The API mentioned above only supports Java, on Android or error, because the reference to Java.beans.Introspector, Android is not supported.
A jar package is provided for the purpose of parsing yaml for Android. Connection: http://download.csdn.net/detail/dgssfgfs/8485943
Import of 2.Jar Packages
Analysis of 3.yaml
- ......
- Import Org.yaml.snakeyaml.Yaml;
- ......
- Yaml ya=new Yaml ();
- HashMap data = (HASHMAP) ya.load (content);
Here load is not a static method, so an object needs to be created.
Java parsing Yaml and Android parsing Yaml