Zum Hauptinhalt gehen

JSON to Dictionary - access data

Kommentare

5 Kommentare

  • Permanently deleted user

    Here's an example of the JSON i'm trying to parse:

     

    {"serviceResponse": {

     

       "statusInfo": {

     

          "mode": "sync",

     

          "status": "success"

     

       },

     

       "fmeTransformationResult": {

     

          "fmeServerResponse": {

     

             "id": "81822",

     

             "jobStatus": "SUCCESS",

     

             "result": "0:Translation Successful|OutputLocation=D:\\a322C555A_1405693053633_4300.zip|ResultRootDir=/fmedatadownloadresults|NumFeaturesOutput=3350|LogFileLocation=D:/FMEServer//Logs/datadownload/FME_322C555A_1405693045147_4300.log|LogFileName=datadownload/FME_322C555A_1405693045147_4300.log",

     

             "resultSuccess": "true",

     

             "serviceMsg": "success",

     

             "serviceSuccess": "true",

     

             "timeRequested": "Fri-18-Jul-2014 03:17:24 PM",

     

             "timeStarted": "Fri-18-Jul-2014 03:17:25 PM",

     

             "timeFinished": "Fri-18-Jul-2014 03:17:33 PM",

     

             "requesterResultPort": "53522",

     

             "requesterHost": "EAME",

     

             "requesterEmail": "",

     

             "request": "\"DMMI/AIMSDM_2_MDSF_mdb/AIMSDM_2_MDSF_mdb.fmw\" -XML_PARAMETER <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<TRANSFORMATION_REQUEST><PUBLISHED_PARAMETER name=\"amp;MaxY\">178602.938891522<\/PUBLISHED_PARAMETER><PUBLISHED_PARAMETER name=\"amp;MaxX\">529258.026827292<\/PUBLISHED_PARAMETER><PUBLISHED_PARAMETER name=\"amp;minY\">177028.884835862<\/PUBLISHED_PARAMETER><PUBLISHED_PARAMETER name=\"amp;minX\">527240.008807216<\/PUBLISHED_PARAMETER><FME_DIRECTIVE name=\"GEODATABASE_MDB_1_DATASET\">!FME_AUTO_DIR_NAME!\\AIMSDM_MDSF2_931.mdb<\/FME_DIRECTIVE><FME_DIRECTIVE name=\"FILECOPY_1_DATASET\">!FME_AUTO_DIR_NAME!\\<\/FME_DIRECTIVE><\/TRANSFORMATION_REQUEST> --FME_SECURITY_ROLES \"fmeuser\"",

     

             "requestKeyword": "FILE_DOWNLOAD_SERVICE",

     

             "priority": "100",

     

             "description": "null"

     

          },

     

          "fmeEngineResponse": {

     

             "statusNumber": "0",

     

             "statusMessage": "Translation Successful",

     

             "outputLocation": "D:\\\\FME_322C555A_1405693053633_4300.zip",

     

             "resultRootDir": "/fmedatadownloadresults",

     

             "numFeaturesOutput": "3350",

     

             "logFileLocation": "D://FME_322C555A_1405693045147_4300.log",

     

             "logFileName": "datadownload/FME_322C555A_1405693045147_4300.log"

     

          }

     

       },

     

       "jobID": 81822,

     

       "url": "http://FME_322C555A_1405693053633_4300.zip"

     

    }}
    0
  • Permanently deleted user

    Newtonsoft.Json.dll (https://json.codeplex.com/) is shipped with the Geocotex Essentails.

    On the workflow, you may use it to extract the information from JSON string.

    I have not used yet by myself, but wish to play around when I have time to do so too.

     

    'Json to Dictionary' activity against your complex Json string is not easy to navigate since it will return as Dictionary<string, Object>. And you need to navigate through  a value (Object type) to reach to the value.

    Try to expriment with Workflow Designer's feature to Run and Debug to find out what 'Json To Dictionary' returns to check it out if you want to see.

    Not much specific help here, but want to give you one possible approach...

    0
  • Permanently deleted user

    Thanks for the excellent reponse here Munwhan. Sorry it's taken meawhile to reply, i think I have a spam filter set on teh geocortex emails!  I'll remove it.

    I have managed to do what I needed based of your response - It appears that the JSON to Dictionary workflow creates nestedIDictionary objects for the nested json objects/arrays.  (somewhat obviously in hindsight!).

    So all I need to do is:

    a) get my JSON as a string

    b) use JSONtoDictionary

    c) cast the key 'serviceResponse' to anther dicionary object iDict_serviceResponse perhaps

    d) query the url key on this new IDict object

    If I want to dig deeper into the structure I can keep casting further iDict objects

    I'm wondering now (in the absence of some decent ways to interact with the JSON model)  if there is away to loop over the nested dictionary object generically normalizing the keys into a new flat dictionary object.  something like newDict("Serviceresponse.url")  or newdict("serviceResponse.statusInfo.success").  If I do this i'll post it here.

    also, many thanks for the 'writeline' debug tool! I'm new to workflow and hadn't spotted that - this makes life a lot easier!

     

     

     

     

    0
  • Permanently deleted user

    Munwham,

    Thank you so much for posting that code. It has been extremely helpfuul. could you please though, tell me what the 3rd command is? (After Writeline - json and before ASsign features Obj = iDictionary1("features") )? I am using a slightly older version of the Workflow designer, and it doesn't come through....

    Ellen

    0
  • Permanently deleted user

    'JsonToDictionary' product activity is suppoed from Geocortex 2.19 and Esentials 3.15.

    0

Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.