Converting Text Analytics for Health response to JSON String

KA 76 Reputation points
2022-06-10T15:48:03.283+00:00

Hello,
Does anyone know if there is a library available to convert the response from Text Analytics for Health on Azure into a JSON String?

I wish this feature was directly available in the TA4H API but it is not there and I am struggling to convert it to a JSON String.
The ultimate goal, by the way, is to use the JSON String to populate a ListView on my Android App.

Azure AI Language
Azure AI Language
An Azure service that provides natural language capabilities including sentiment analysis, entity extraction, and automated question answering.
353 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Lloyd Sheen 1,376 Reputation points
    2022-06-10T21:48:29.867+00:00

    I use the JSON convert lib from Newtonsoft. There are both a DeserializeObject and SerializeObject methods that will create classes from a string and create a string from classes. Free, fast and easy to use.


  2. Stuart Dobson 6 Reputation points
    2022-09-13T23:36:48.517+00:00

    Either Newtonsoft or the new System.Text.Json should be able to parse Json no matter how nested.

    What you need to do is create classes which match the structure and hierarchy.

    For example:

    class Role  
    {  
        string Name { get; set; }  
    }  
    
    class Employee  
    {  
        string EmployeeName { get; set; }  
        Role Role { get; set; }  
    }  
    
    var json= JsonSerializer.Serialize<Employee>(employee);  
    

    should create something like

    {  
        "Employee" :   
            {  
                "EmployeeName": "Bob",  
                "Role" : {  
                                 "Name": "Sales"  
                             }  
             }  
    }  
    

    Please don't forget to click Accepted Answer and Upvote whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer.

    0 comments No comments