File tree 4 files changed +51
-11
lines changed
4 files changed +51
-11
lines changed Original file line number Diff line number Diff line change
1
+ {
2
+ "colorsArray" :[{
3
+ "colorName" :" red" ,
4
+ "hexValue" :" #f00"
5
+ },
6
+ {
7
+ "colorName" :" green" ,
8
+ "hexValue" :" #0f0"
9
+ },
10
+ {
11
+ "colorName" :" blue" ,
12
+ "hexValue" :" #00f"
13
+ },
14
+ {
15
+ "colorName" :" cyan" ,
16
+ "hexValue" :" #0ff"
17
+ },
18
+ {
19
+ "colorName" :" magenta" ,
20
+ "hexValue" :" #f0f"
21
+ },
22
+ {
23
+ "colorName" :" yellow" ,
24
+ "hexValue" :" #ff0"
25
+ },
26
+ {
27
+ "colorName" :" black" ,
28
+ "hexValue" :" #000"
29
+ }
30
+ ]
31
+ }
Original file line number Diff line number Diff line change
1
+ import sys
2
+ import json
3
+ import yaml
4
+
5
+ """
6
+ Example usage:
7
+
8
+ $ python 29_json_to_yaml.py 29_json_test.json
9
+ """
10
+
11
+ # load json data
12
+ json_data = json .loads (open (sys .argv [1 ]).read ())
13
+ # convert unicode to string
14
+ converted_json_data = json .dumps (json_data )
15
+ # output yaml
16
+ print (yaml .dump (yaml .load (converted_json_data ), default_flow_style = False ))
Original file line number Diff line number Diff line change 4
4
1 . ** 02_find_all_links.py** : get all links from a webpage
5
5
1 . ** 03_simple_twitter_manager.py** : accessing the Twitter API, example functions
6
6
1 . ** 04_rename_with_slice.py** : rename group of files, within a single directory, using slice
7
- 1 . ** 05_load_json_without_dupes.py** : load json , convert to dict, raise error if there is a duplicate key
7
+ 1 . ** 05_load_json_without_dupes.py** : load JSON , convert to dict, raise error if there is a duplicate key
8
8
1 . ** 06_execution_time.py** : class used for timing execution of code
9
9
1 . ** 07_benchmark_permissions_loading_django.py** : benchmark loading of permissions in Django
10
10
1 . ** 08_basic_email_web_crawler.py** : web crawler for grabbing emails from a website
27
27
1 . ** 25_ip2geolocation.py** : Given a CSV file with an ip address (see sample - * 25_sample_csv.csv* ), return the geolocation based on the ip.
28
28
1 . ** 26_stock_scraper.py** : Scrape the S&P 500 Companies list from Wikipedia, then output the data.
29
29
1 . ** 27_send_sms.py** : Send SMS message via [ TextBelt] ( http://textbelt.com/ )
30
- 1 . ** 28_income_tax_calculator.py** : Income tax calcuator via [ Taxee] ( http://taxee.io/ )
30
+ 1 . ** 28_income_tax_calculator.py** : Income tax calculator via [ Taxee] ( http://taxee.io/ )
31
+ 1 . ** 29_json_to_yaml.py** : Convert JSON to YAML
Original file line number Diff line number Diff line change 1
- Flask == 0.10.1
2
- Jinja2 == 2.7.3
3
- MarkupSafe == 0.23
4
- Wand == 0.4.0
5
- Werkzeug == 0.10.4
6
- hurry.filesize == 0.9
7
- itsdangerous == 0.24
8
- lxml == 3.4.4
9
- numpy == 1.9.2
1
+ PyYAML == 3.11
10
2
requests == 2.7.0
11
3
wheel == 0.24.0
You can’t perform that action at this time.
0 commit comments