none
Deployr .Net Client library and JSON strings RRS feed

  • Question

  • Hi everyone

    Scenario:

    I have a set of inputs that I need to pass through to the deployr server. Certain parameters are simple strings but others are JSON strings that get converted by the R script by calling fromJSON.

    Problem

    When I pass the simple string values to the server they are fine but when I try pass a JSON formatted string to the server, the script execution fails. This script has been tested locally and using it via the R.Net library also works. Unfortunately R.Net does not suite our use case as we need multi threading.

    Example:

    var jsonString = RDataFactory.createString("jsonData", File.ReadAllText("Data/jsonData.txt"));
    
    taskOptions.rinputs.Add(jsonString);
    
    //Execute request ....

    Where the JSON data looks like this

    //jsonData.txt
    {"ID":77674,"Name":"My Company","CurrencySymbol":"R"}

    And the R call failing is

    deployrInput('{ "name": "jsonData", "default": "", "render": "character" } ')
    mydata <- fromJSON(jsonData)

    Question:

    How do I pass a raw string that is JSON formatted as an rinput to the deployr server?

    Please forgive me if it is something small, relatively new to all this and couldn't find anything helpful in the docs.

    Thanks in advance!



    Take me back to the days were corrupt politicians were put to death ...

    Friday, July 8, 2016 2:40 PM

Answers

  • Figured it out. Seems the "rjson" package doesn't play nicely with DeployR.

    Using the package "jsonlite" resolved the issue.

    Take me back to the days were corrupt politicians were put to death ...

    • Marked as answer by Rabid Dog Monday, July 11, 2016 11:26 PM
    Monday, July 11, 2016 11:26 PM