Skip to content

Commit

Permalink
fix: Correct JSON parsing by removing code block markers
Browse files Browse the repository at this point in the history
  • Loading branch information
csulit committed Oct 25, 2024
1 parent 93c9d80 commit 0aaa465
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion config/deno-kv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,11 @@ export async function listenQueue(kv: Deno.Kv) {
);

try {
JSON.parse(aiGeneratedDescription.replace("```", "```json"));
JSON.parse(
aiGeneratedDescription
.replace("```", "")
.replace("```json", "")
);
} catch {
throw Error("Invalid AI description format");
}
Expand Down
2 changes: 1 addition & 1 deletion server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ app.get("/api/properties/:id", async (c: Context) => {

try {
// Verify the aiDescription is valid JSON by parsing it
JSON.parse(aiDescription.replace("```", "```json"));
JSON.parse(aiDescription.replace("```", "").replace("```json", ""));

propertyData.ai_generated_description = aiDescription;

Expand Down

0 comments on commit 0aaa465

Please sign in to comment.