Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
19b5cb1e
Unverified
Commit
19b5cb1e
authored
Jun 02, 2023
by
John Wang
Committed by
GitHub
Jun 02, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: fix json end with `` (#285)
parent
2478c88e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
0 deletions
+6
-0
json_in_md_parser.py
api/libs/json_in_md_parser.py
+6
-0
No files found.
api/libs/json_in_md_parser.py
View file @
19b5cb1e
...
@@ -13,6 +13,12 @@ def parse_json_markdown(json_string: str) -> dict:
...
@@ -13,6 +13,12 @@ def parse_json_markdown(json_string: str) -> dict:
if
start_index
!=
-
1
and
end_index
!=
-
1
:
if
start_index
!=
-
1
and
end_index
!=
-
1
:
extracted_content
=
json_string
[
start_index
+
len
(
"```json"
):
end_index
]
.
strip
()
extracted_content
=
json_string
[
start_index
+
len
(
"```json"
):
end_index
]
.
strip
()
# Parse the JSON string into a Python dictionary
parsed
=
json
.
loads
(
extracted_content
)
elif
start_index
!=
-
1
and
end_index
==
-
1
and
json_string
.
endswith
(
"``"
):
end_index
=
json_string
.
find
(
"``"
,
start_index
+
len
(
"```json"
))
extracted_content
=
json_string
[
start_index
+
len
(
"```json"
):
end_index
]
.
strip
()
# Parse the JSON string into a Python dictionary
# Parse the JSON string into a Python dictionary
parsed
=
json
.
loads
(
extracted_content
)
parsed
=
json
.
loads
(
extracted_content
)
elif
json_string
.
startswith
(
"{"
):
elif
json_string
.
startswith
(
"{"
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment