Skip to content

Json parsing fix#1

Open
pranitl wants to merge 5 commits intoboringmarketer:mainfrom
pranitl:json-parsing-fix
Open

Json parsing fix#1
pranitl wants to merge 5 commits intoboringmarketer:mainfrom
pranitl:json-parsing-fix

Conversation

@pranitl
Copy link
Copy Markdown

@pranitl pranitl commented Jun 17, 2025

Issue 1: Improper JSON parsing from PPLX API

After running the initial version, I ran in to issues where the tool was providing keyword suggestions like:

"clusters": [
    {
      "cluster_id": 1,
      "main_keyword": "```json",
      "theme": "🎯 General",
      "keywords": [
        {
          "keyword": "```json",
          "search_volume": 49500,
          "cpc": 3.33,
          "competition": "LOW",
          "competition_level": "unknown",
          "keyword_difficulty": 0,
          "serp_urls": [],
          "commercial_score": null,
          "is_seed": false
        }
      ],
      "total_search_volume": 49500,
      "avg_cpc": 3.33,
      "avg_difficulty": 0,
      "total_commercial_score": null,
      "competitor_domains": []
    },
    {
      "cluster_id": 2,
      "main_keyword": "json",
      "theme": "🎯 General",
      "keywords": [
        {
          "keyword": "json",
          "search_volume": 49500,
          "cpc": 3.33,
          "competition": "LOW",
          "competition_level": "unknown",
          "keyword_difficulty": 0,
          "serp_urls": [],
          "commercial_score": null,
          "is_seed": false
        },
        {
          "keyword": "json to google sheets",
          "search_volume": 320,
          "cpc": 4.01,
          "competition": "LOW",
          "competition_level": "unknown",
          "keyword_difficulty": 0,
          "serp_urls": [],
          "commercial_score": null,
          "is_seed": false
        },
        {
          "keyword": "json to csv",
          "search_volume": 9900,
          "cpc": 8,
          "competition": "LOW",
          "competition_level": "unknown",
          "keyword_difficulty": 0,
          "serp_urls": [],
          "commercial_score": null,
          "is_seed": false
        },
        {
          "keyword": "json to csv converter",
          "search_volume": 2400,
          "cpc": 4.76,
          "competition": "LOW",
          "competition_level": "unknown",
          "keyword_difficulty": 0,
          "serp_urls": [],
          "commercial_score": null,
          "is_seed": false
        },
        {
          "keyword": "json file",
          "search_volume": 18100,
          "cpc": 2.74,
          "competition": "LOW",
          "competition_level": "unknown",
          "keyword_difficulty": 0,
          "serp_urls": [],
          "commercial_score": null,
          "is_seed": false
        },
        {
          "keyword": "import json to google sheets",
          "search_volume": 140,
          "cpc": 0,
          "competition": "LOW",
          "competition_level": "unknown",
          "keyword_difficulty": 0,
          "serp_urls": [],
          "commercial_score": null,
          "is_seed": false
        },
        {
          "keyword": "json api",
          "search_volume": 1600,
          "cpc": 20.86,
          "competition": "LOW",
          "competition_level": "unknown",
          "keyword_difficulty": 0,
          "serp_urls": [],
          "commercial_score": null,
          "is_seed": false
        },
        {
          "keyword": "json database",
          "search_volume": 1600,
          "cpc": 13.12,
          "competition": "LOW",
          "competition_level": "unknown",
          "keyword_difficulty": 0,
          "serp_urls": [],
          "commercial_score": null,
          "is_seed": false
        },
        {
          "keyword": "json decoder",
          "search_volume": 1900,
          "cpc": 0,
          "competition": "LOW",
          "competition_level": "unknown",
          "keyword_difficulty": 0,
          "serp_urls": [],
          "commercial_score": null,
          "is_seed": false
        },
        {
          "keyword": "json reader",
          "search_volume": 2400,
          "cpc": 0.15,
          "competition": "LOW",
          "competition_level": "unknown",
          "keyword_difficulty": 0,
          "serp_urls": [],
          "commercial_score": null,
          "is_seed": false
        }
        

I proposed a fix by just adding a simple filter on the techinical jargon terms to prevent this as well as a more resilient JSON parsing logic from Perplexity's API to prevent these issues in the future.

pranitl added 5 commits June 17, 2025 18:18
…nt keywords based on search volume and technical criteria.
- Introduced `extractJsonFromAiResponse` to handle JSON extraction from AI responses, with fallbacks for malformed JSON.
- Updated keyword generation logic to utilize the new helper function for cleaner and more reliable parsing of content.
- Enhanced competitor analysis to use the same extraction method for consistency in data handling.
@vercel
Copy link
Copy Markdown

vercel bot commented Jun 17, 2025

@pranitl is attempting to deploy a commit to the james-boringmarket's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accidentally uploaded sample output for a sample business.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant