Need Help with Javascript:

Hi Guys,

I have a JSON

  "great",
  "check",
  "good",
  "amazing",
  "visit",
  "cbd",
  "nice",
  "wow",
  "star_boss__prasad",
  "poojarao108",
  "ambrishthakurthakur",
  "clinic",
  "hemp",
  "seeds",
  "awesome",
  "products",
  "shalabhrao",
  "woww",
  "gonna",
  "bro",
  "sir",
  "weight",
  "plz",
  "delhi",
  "kaise",
  "saans",
  "rehe",
  "ho?",
  "niranjanvnaik",
  "boon",
  "experience",
  "superb",
  "recommendation",
  "wow!",
  "checking",
  "jiasingh",
  "glad",
  "hear",
  "this!",
  "voiceover",
  "videos",
  "beautiful",
  "incredibly",
  "informative",
  "noticeable",
  "improvement",
  "super",
  "loadingmiles",
  "couldn’t",
  "agree",
  "more!",
  "grow",
  "wiser",
  "understand",
  "holistic",
  "wellness",
  "located",
  "bangalore",
  "adityamendonca",
  "ooo",
  "love",
  "adding",
  "topping",
  "oats!",
  "hear!",
  "yogacaro",
  "favourite",
  "danesmedical",
  "it’s",
  "benefits",
  "highlighted",
  "mainstream",
  "i’ve",
  "fantastic",
  "grubmode",
  "host",
  "interesting",
  "place",
  "disharajputx",
  "consult",
  "doctor?",
  "wonderful",
  "ma’am",
  "nyc",
  "video",
  "city",
  "india",
  "uuk",
  "worst",
  "hyderabad",
  "soo",
  "surely",
  "woww!!!!",
  "sounds",
  "worth",
  "loved",
  "fabulous",
  "content",
  "post",
  "_fashionnfuel_"
]```

I am trying to clean it up by using JS so that I can get all these word separated by ","

I am using this JS

let inputArray;
try {
inputArray = JSON.parse(p1 || ‘’); // Parse p1 as JSON
} catch (e) {
return ‘Invalid JSON input’; // Handle invalid JSON
}

const cleanedArray = inputArray
.map(item => item.trim().replace(/[^a-zA-Z0-9]/g, ‘’)) // Remove special characters
.filter(item => item !== ‘’); // Remove empty strings

return cleanedArray.join(‘,’);




I am not getting anything, I understand that p1 which is m JSON is not accepted input.

Can you guys help me how can I solve this issue?

Thank you in advance for helping me.

Regards,
Dilip

You don’t need JavaScript. Instead use a Query JSON column.

$join($,",")
2 Likes

Hi @Darren_Murphy ,

Thank you it works amazingly well.

I had one more question.

Is there any such short cut to extract Value from a JSON object?

{
“Bangalore”: 36.36,
“Delhi”: 9.09,
“Mumbai”: 9.09,
“Dubai”: 9.09,
“Hyderabad”: 9.09,
“Others”: 36.36
}

I need to extract values of this.

Is Javascript the only way?

Regards,
Dilip

You can also use Query JSON, but I’m not clear what you want. What would you expect the result to be?

Hi @Darren_Murphy ,

Thank you for replying

EX:

{
“2024-10-12”: {
“reach”: 7899418
},
“2024-10-13”: {
“reach”: 7899500
},
“2024-10-14”: {
“reach”: 7899700
}
}

this will basically be accumulated over time. which I would need to plot the reach and dates on a graph

I would need the latest 5 dates which is Key and Latest 5 values corresponding to dates.

Let me know if you need more clarity.

Thank you again.

Regards,
Dilip

Given the above input, please show me your expected output.

Hi @Darren_Murphy ,

Thank you for replying.

I am sorry, I just put information out wrongly.

I am getting JSON array like this

[
  {
    "2025-01-08": {
      "reach": 1526178
    }
  },
  {
    "2025-01-09": {
      "reach": 1547229
    }
  },
  {
    "2025-01-10": {
      "reach": 1547465
    }
  }
]

I am to able to use JS to convert it.

I want one column to have my dates like this
2024-10-12,2024-10-13,2024-10-14

Other column to have values like this

7899418, 7899500, 7899700

if there are more key or values all those values should come separated by comma

Regards,
Dilip

So do you mean you want to add this dynamically to a table? With one row per item and a column for date and reach?

If so - that can be achieved - just confirm that’s what you’re after and we will explain how!

Hi @Andrew_Davies ,

thank you for responding.

No no I just want to add it to another column with comma separation.

Regards,
Dilip

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.