Json object not recongized (newbie question)

All, I am so sorry for this really silly quesiton, but i have wasted way too much time trying to figure it out, so bear with me:

I am simply trying to convert an unformatted URL www.ExAmple.com and turn into a nicely formatted ‘https://example.com’ in a json object. Then use this json object in the next node for a http request. But somehow the http node doesnt recognize my object / the url. What am i doing wrong? (n8n’s chat bot told me to use ‘json/parse’, but somehow i do it wrong becaue it doesnt work ALSO this seems too complicated for the easy thing i am trying to achieve.
Sorry for this silly question!

Hi @fengelh
what is your exact use case?

To do that thing you can use an expression like this:
{{ $json.url.includes("http://") ? $json.url.toLowerCase() : "http://" + $json.url.toLowerCase() }}

This also:

  • checks if http:// is already there (adds it only if it’s not there)
  • also lower the case with toLowerCase(), you can remove it if you don’t want it

Here’s an example in a demo workflow:

Let me know if that helps

1 Like

Thanks, but i dont think this is quiet what i am going for . Sorry if i was unclear.
I basically want to grab the url that i identified in the previous node (OpenAI on the left = https://kkr.com), and use that url in the current node to add a path to it “/robots.txt. Then I would like to scrape this new URL https://kkr.com/robots.txt. But in my current setup the reference ‘{{ $json.message.content }}/robots.txt’ picks up not the url htt[s://kkr.com, but the entire string (”“json\n{"baseURL": "https://kkr.com"}\n”" → therefore i cant build that url that i want to scrape. I hope that makes sense.

Hi @fengelh
sorry I misunderstood the question
Have you tried switching the Output Content as JSON option in the Open AI node? That should provide the output as a JSON instead of a string and make things much easier.

Example here:

Let me know!

1 Like

Oh my god, thats it. So sorry for the silly question, yet thank you so very much for that answer and taking the time to look at my noob question! I feel very silly now. Thanks a lot again!

1 Like

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