Convert JSON to XML format through Azure Logic app - xml-parsing

Scenario 1 - I have some XML files stored in FTP.Those files are being fetched by FTP connector in Azure logic app. Then I am reading those files by parsing it into JSON & storing those objects in String variables for my operation. Then after my processing I want to convert that json back to XML for the output.
Scenario 2 - I am merging multiple XMl files(all are of same structure) into an single one. after merging I can get the output in JSON format but then I want to convert the same into XML format.
So please suggest how can I convert JSON to XML through Logic App & Azure function only.

Try the 'xml' function.
screenshot of xml function example in Logic App
Make sure that your JSON input is structured suitably for conversion to XML, for example you should only have a single element at the top level, which will form your XML root element.

Related

Data parsing and sending from DICOM image in .net core

I am currently working on a complete DICOM Web application based on .net core + Postgresql and OHIF viewer ( to render DICOM images).
I've built a database with tables as Patient, Study, etc. and the attributes I am storing as PatientName, PatientDOB, etc. now while returning the json the output is also the same as
"PatientName" : "temp"
"PatientDOB" : "2332"
..
but as DICOM viewers have a standard in which they recieve JSON objects as
{
"0020000D": {
"vr": "UI",
"Value": [ "1.2.392.200036.9116.2.2.2.1762893313.1029997326.945873" ]
}
}
so I want to map my JSON input/output in such a way that while returning I return values in above Dicom format and while getting the data I store them as attributes (column names) and not as tags?
I am pretty new in .net core and Dicom web so how to proceed further with that? Also, I am using fo-Dicom to read the data from Dicom image.
Please provide some hint/code that I can use.
You will propably store only few DicomTags into your database (the tags you need for doing a query against your database), but the viewer may want to have all the tags as Json. So I would not try to map your database-Jasons into Dicom-jsons, but I would use fo-dicom to generate the Json out of the DICOM file:
You need to add the nugeg package fo-dicom.json and then you can call
DicomDataset dataset = ... // wherever you get your DICOM file
string json = JsonConvert.SerializeObject(dataset, new JsonDicomConverter());
or the othe way round, if you want to convert such a DICOM conformant json into a DicomDataset
string json = ... // wherever you get the json from
DicomDataset dataset = JsonConvert.DeserializeObject<DicomDataset>(json, new JsonDicomConverter());
OHIF Viewer supports the standard DICOMweb WADO-RS JSON metadata format in addition to the custom format you mentioned in your question. This means you can use any DICOMweb server such as Orthanc, DCM4CHE or DICOMcloud
DICOMcloud may fit your scenario better as it uses fo-dicom. However, it currently only support MS SQL Server and .NET 4.6. (there is an effort to support mySQL but it is not 100% completed)
If you still want to write your own, you can look of how it is implemented and adapt it to your own solution.
[Disclosure] I am the author of DICOMcloud

How to save response in a variable in jmeter

I am performing load testing on my server using jmeter.
In one of my post requests, I receive a unique id in the response.
I need to send this id as a parameter in the following post requests.
I am new to jmeter and don't have any idea how to do this.
Help would be really appreciated.
If you need to store the whole response into a variable - take the following steps:
Add Beanshell PostProcessor as a child of the request which returns response you're looking for
Put the following line into the PostProcessor's "Script" area:
vars.put("response", new String(data));
Refer extracted value as ${response} where required
See How to Use BeanShell: JMeter's Favorite Built-in Component guide to lean more about Beanshell scripting in JMeter
Alternatively you can do the same with the Regular Expression Extractor, in that case relevant configuration will be:
Reference Name: response
Regular Expression: (?s)(^.*)
Template: $1$
If you need a part of response, not the whole response you can amend Regular Expression according to your needs as per Regular Expressions chapter of JMeter's User Manual
If you really need to store the whole response into a variable, do the following:
Add JSR223 PostProcessor as a child of the request which returns response you're looking for
Put the following line into the "Script" area:
vars.put("response", prev.getResponseDataAsString());
Use then this response as ${response} where you need it
But you rarely need to use the whole response and you should avoid it for big , in this case it is much better to use the Extractor that suits your response format:
JSON Extractor for JSON
CSS/JQuery Extractor for HTML extraction
XPath Extractor for XML
Regular Expression Extractor for all of them or any textual format
You can use JMeter's Post-Processor Regular Expression Extractor to extract the required value from response. Just Add this under the sampler whose response will contain the required value.
In Reg expression extractor, you will define the variable name (referenceName), RegularExpression, template etc. Later you can use the value in this variable. To learn how to use Reg expression extractor you can refer to following tutorial.
https://docs.blazemeter.com/customer/portal/articles/1743642-using-regex-regular-expression-extractor-with-jmeter
I know this question is old but I agree with #UBIK you should probably use a JSON extractor. I am working with a load test that is sending over 100 requests per second and I need to reuse the value in a specific JSON key, so I'm using a JSON extractor and saving the values in a .csv file to be used by the next request.
extract the JSON
This is the Groovy script to write it to a .csv file
def myRandomIds = new File("randomIds.csv")
myRandomIds << vars.get("id") + ","
myRandomIds << System.getProperty("line.separator")
log.info(vars.get("id") + " saved to randomIds.csv...")
This is the CSV data config I have set up in my other request that is reading from the csv file. (In my case these .jmx files are automated and parametized using jenkins)
CSV data set config

Is there any tools available for converting JSON data to Avro on the fly?

I need a utility to convert my incoming JSON data(on which I have no control) to Avro Format(on the fly)ie. without using any Hive query, MR job etc.
I am able to generate the avrso schema perfectly.
I am aware that we do have an Avro Tool for the purpose.
From JSON to Avro: DataFileWriteTool
From Avro to JSON: DataFileReadTool
But the challenge is that it accepts JSON data in a typesafe format types.I am facing the exact same issue when I try to use this tool.
How to fix Expected start-union. Got VALUE_NUMBER_INT when converting JSON to Avro on the command line?
Any pointers/help ?

xml parsing in ios and putting parsed data in array

I am trying to parse the xml file in xcode and store data in different arrays for different keys.My xml file is like as follows:
<Colleges>
<College>
<id>1</id>
<Name>abc</Name>
<Branches>
<Branch>a</Branch>
<Branch>b</Branch>
</Branches>
</College>
..... And many colleges....
</Colleges>
Can any one please give me the sample code to parse this file and put in separate arrays. I have knowledge of delegate methods but failed to implement them. I think I am lacking some were in between.
Try this: Simple XML to NSDictionary Converter. The two files will help you to convert your XML data to NSDictionary from which you can easily get your array.

XML Schema - Allow Invalid Dates

Hi I am using biztalk's FlatFile parser (using XML schema) to part a CSV file. The CSV File sometimes contains invalid date - 1/1/1900. Currently the schema validation for the flat file fails because of invalid date. Is there any setting that I can use to allow the date to be used?
I dont want to read the date as string. I might be forced to if there is no other way.
You could change it to a valid XML date time (e.g., 1900-01-00:00:00Z) using a custom pipeline component (see examples here). Or you can just treat it as a string in your schema and deal with converting it later in a map, in an orchestration, or in a downstream system.
Here is a a C# snippet that you could put into a scripting functoid inside a BizTalk map to convert the string to an xs:dateTime, though you'll need to do some more work if you want to handle the potential for bad input data:
public string ConvertStringDateToDateTime(string param1)
{
return DateTime.Parse(inputDate).ToString("s",System.Globalization.DateTimeFormatInfo.InvariantInfo);
}
Also see this blog post if you're looking to do that in multiple places in a single map.

Resources