Parse data in plain text?

Hi,

I have plain text as data, the data involves questions and answers. This can be think as key/value. and I want to parse this plain text into JSON. Do you know how I can do this in make? I can do it in javascript.

My plain text data is only a question and answer flow like this;

Question: Answer

Question: Answer

Hi @onurbolaca,

Not sure about how your desired output JSON looks like, but the simplest way you can do is using iterator and text aggregator.

  1. Setup Iterator that will split the plain text you are getting using newline
    Screenshot from 2023-05-19 19-33-51
  2. Setup the Text Aggregrator, that will split the result using colon as the seperator.

β€œ{{trim(first(split(2.value; β€œ:”)))}}” : β€œ{{trim(last(split(2.value; β€œ:”)))}}”

This implementation has few issues, also add a filter in between iterator and aggregator to check if the text is empty.

2 Likes

Hello again @onurbolaca :blush:

Any luck putting @Runcorn’s proposed flow to work? Did it maybe help you accomplish what you’re been trying to do?

We’re eager to hear how things are coming together and would love an update on your progress :nerd_face:

This approached worked for me and helped me a lot.

I parsed as key and value with the static structure of my text.

It became something like this: