Regarding Data to JSON operator for proper JSON output

SanSan Member Posts: 15 Contributor I
edited January 2021 in Help
I am using readdatabases operator and querying the data.I am getting json data in one column of example set as a result but when i try to again convert data to json it is adding / \ slashes to each value and attribute in json. Can anyone help me how can i eliminate that and get the json data as it is displayed in the exampleset attribute column

Answers

  • BalazsBaranyBalazsBarany Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert Posts: 955 Unicorn
    Hi,

    this is the expected behaviour. In your case, you already have JSON data. Data to JSON doesn't know that, it handles your JSON attribute as a normal text attribute, and converts it *again* into standard JSON, which has to escape the "s with \. 

    You could split up your example set: select all attributes but the JSON one into one table, keep the JSON attribute in another, keep a common ID (maybe create it with Generate ID if you don't have one) and join later for example.

    Best regards,
    Balázs
  • SanSan Member Posts: 15 Contributor I
    Hi, actually there is only 1 column in my example set that has the json data.. but I need the example set in json so how do I split up? Or how do I do it?
  • BalazsBaranyBalazsBarany Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert Posts: 955 Unicorn
    Hi!

    So you already have JSON data? Why are you using "Data to JSON" then? 
    I don't understand what you need by "I need the example set in json so how do I split up".
    Either you need the JSON, you already have that.
    Or you want so split up into different attributes. Use JSON to Data (from the Text Processing extension) for that, or the functionality in the database if that exists. There's also Extract Information where you can use JSONPath to access parts of your document.

    Regards,
    Balázs
  • SanSan Member Posts: 15 Contributor I
    Hello, 
    Actually, what I meant is... I am getting whole JSON data in single column in Exampleset. But what I want is the actual JSON structure with JSON data as output. Not the JSON data present in table......
  • BalazsBaranyBalazsBarany Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert Posts: 955 Unicorn
    Can you provide examples? What you have, what you want?
  • SanSan Member Posts: 15 Contributor I
    edited January 2021
    Hi, 
    For better understanding I am attaching a picture here, Please do take a look. Below picture is the output of Read database operator which is Exampleset. But What I am expecting is actual JSON structure with JSON format as output. 
  • BalazsBaranyBalazsBarany Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert Posts: 955 Unicorn
    You already have an actual JSON structure with JSON format in the syselement attribute. Please explain what problem you're trying to solve.
  • SanSan Member Posts: 15 Contributor I
    Hi, yes but I need to do data to json to that because the json is in example set format and in attribute syselement. I want it as a fresh only json like what we get when we do data to json 
  • BalazsBaranyBalazsBarany Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert Posts: 955 Unicorn
    Hi,

    you can use "Data to Documents" to convert the example set format to a collection of documents, similarly to "Data to JSON". 
    Use "Nominal to Text" to convert the JSON attribute to a text attribute, and "Data to Documents" will pick it up.

    Regards,
    Balázs
  • SanSan Member Posts: 15 Contributor I
    Thank you will try it out 
Sign In or Register to comment.