Skip to main content
Solved

Parse json in a task

  • December 21, 2022
  • 3 replies
  • 105 views

Blommetje
Forum|alt.badge.img+13

Hi,

I would like to process some json content. The code I have to process it works quite well, except that I do not know how to access the file in the gui. 

I currently have a task, with a file upload and a Functionality. This func. writes the json data into the db. 

However, instead of the contents of the file, it tried to process the filename, not the contents. 

Also, I would like to handle the file without uploading and storing it in Azure, since I do not need the file afterwards. 

Any guidance in this would be very welcome. 

Thanks, 

Alexander 

Best answer by Mark Jongeling

Hi Alexander,

You could make a Process flow that starts with a Start (table) task process action. That task should have two task parameters, one for the file name (domain with file upload - Database storage type) and one for its file data. These parameters can then be linked with process variables.

Now you have the file data inside the process variable and you can do anything with it.

Hope this helps!

View original
Did this topic help you find an answer to your question?
This topic has been closed for comments

3 replies

Mark Jongeling
Administrator
Forum|alt.badge.img+23
  • Administrator
  • 3936 replies
  • Answer
  • December 21, 2022

Hi Alexander,

You could make a Process flow that starts with a Start (table) task process action. That task should have two task parameters, one for the file name (domain with file upload - Database storage type) and one for its file data. These parameters can then be linked with process variables.

Now you have the file data inside the process variable and you can do anything with it.

Hope this helps!


Blommetje
Forum|alt.badge.img+13
  • Author
  • Partner
  • 209 replies
  • December 22, 2022

Hi Mark, 

Well, I have a PF that does something. 1 start task - upload file. 
Task 2 - with a template to process the file. 

But the var ‘file_content’ is now - according to the PF monitor set with value ‘System.Byte[]’ and the code processing the data states; 

JSON text is not properly formatted. Unexpected character '祓' is found at position 0.
or, we fiddling;  Unexpected character 'ൻ' is found at position 0.

So, somewhere something is off, since i’m not formatting an asian language..

I have two vars. 1 file_upload (databse), 1 file_content. he domain for this var is a varbinary(max).

Quite lost on this. 

Also, I don’t see the file/data in my db. I have made a table for this, with 3 columns. PK, file_name, file_content. Yet.. no records. Where/how can I spec that the file needs to go in said table? 
 


Mark Jongeling
Administrator
Forum|alt.badge.img+23

Could it be that you try to convert the data into nvarchar(max)? If you make that varchar(max) instead, does that solve it?

The Task will not automatically add it to your table, you’ll have to write the insert into statement for it, using the variables as select values. E.g.:

insert into json_table
(
    file_name,
    file_data,
    file_data_in_text
)
select 
    @file_name,
    @file_data,
    convert(varchar(max), @file_data)

 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings