Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -383,24 +383,33 @@ Required keys:
|
|
383 |
|
384 |
def format_json(inp):
|
385 |
new_json=[]
|
|
|
386 |
print("FORMATTING:::")
|
387 |
for i,line in enumerate(inp):
|
388 |
line = line.strip()
|
|
|
|
|
|
|
389 |
#print(f'test:: {line}')
|
390 |
if "keywords" in line and ":" in line:
|
|
|
391 |
print (line)
|
392 |
if "title" in line and ":" in line:
|
|
|
393 |
print (line)
|
394 |
if "description" in line and ":" in line:
|
|
|
395 |
print (line)
|
396 |
if "content" in line and ":" in line:
|
|
|
397 |
print (line)
|
398 |
if "url" in line and ":" in line:
|
|
|
399 |
print (line)
|
400 |
-
|
401 |
-
print (line)
|
402 |
if "}" in line:
|
403 |
-
|
|
|
404 |
|
405 |
|
406 |
|
|
|
383 |
|
384 |
def format_json(inp):
|
385 |
new_json=[]
|
386 |
+
start_json={}
|
387 |
print("FORMATTING:::")
|
388 |
for i,line in enumerate(inp):
|
389 |
line = line.strip()
|
390 |
+
if "{" in line:
|
391 |
+
print (line)
|
392 |
+
start_json={}
|
393 |
#print(f'test:: {line}')
|
394 |
if "keywords" in line and ":" in line:
|
395 |
+
start_json['keywords']=line.split(":")[1].strip(",")
|
396 |
print (line)
|
397 |
if "title" in line and ":" in line:
|
398 |
+
start_json['title']=line.split(":")[1].strip(",")
|
399 |
print (line)
|
400 |
if "description" in line and ":" in line:
|
401 |
+
start_json['description']=line.split(":")[1].strip(",")
|
402 |
print (line)
|
403 |
if "content" in line and ":" in line:
|
404 |
+
start_json['content']=line.split(":")[1].strip(",")
|
405 |
print (line)
|
406 |
if "url" in line and ":" in line:
|
407 |
+
start_json['url']=line.split(":")[1].strip(",")
|
408 |
print (line)
|
409 |
+
|
|
|
410 |
if "}" in line:
|
411 |
+
new_json.append(start_json)
|
412 |
+
print (new_json)
|
413 |
|
414 |
|
415 |
|