0

I have a flat file(.txt) generated from a web service having the contents something as below:

Field1 Field2

""key1": [{"somekey":"somevalue"}], "key2": "somevalue2" testvalueforfield2 

As you can see from above structure Field1 of my flat file contains a JSON based response. I want the JSON response to be extracted and written to a .json file. I'm not able to extract the JSON response from my flat file. Can anyone help me so as to which transformations and/or components I must use to get this done ?

Update: I'm using a hierarchy parser to extract fields from my json value present in flat file but nothing comes up in the target file

4
  • 1
    A bit more info might be needed. Is that a response from some REST service? Do you get a file or a response? Are you using Data Integration (CDI) module, or Application Integration (CAI) module? Commented Mar 23, 2023 at 12:47
  • @Maciejg I'm using a rest connection inside a business service and using that I am able to generate above response to a flat file. I'm using a Data Integration module currently Commented Mar 23, 2023 at 13:35
  • 1
    Rather than extracting from a file you could pass the rest response to Hierarchy Parser that would parse it and give you the values. If you NEED to read from a file, that is a different problem - as Data Integration will read the file line-by-line, basically cutting your JSON to pieces. To avoid that you'd need to set the line delimeter to some non-existing string, havig full JSON in single field as a result. Commented Mar 23, 2023 at 14:45
  • I tried this. However I receive an error in my job as [ERROR] Failed to process data: parse error: Syntax error while parsing ':'-. The job is a success but 0 rows are processed. Also the preview for hierarchy parser is empty. Commented Mar 23, 2023 at 18:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.