Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Please Help Me Parse Out A Name:Value

2012-05-20
2013-05-28
  • Elie Grunhaus
    Elie Grunhaus
    2012-05-20

    Hi.

    I'm very new to using PLJSON.  I have the following JSON object:

    {

        "shift": "2012-04-20",
        "start": "2012-04-20 00:00:00",
        "stop": "2012-04-21 00:00:00",
        "start_sec": 1334905200,
        "stop_sec": 1334991600,
        "instrument_names": ,
        "beam_destination_names": ,
        "beam_destinations": { … },
        "total_beam_destinations": "24 hr 00 min",
        "total_beam_destinations_sec": 86400,
        "lcls_status": ,
        "total_beam_time_sec": 35778.626697063,
        "total_beam_time": "09 hr 56 min",
        "total_data_taking": "04 hr 12 min",
        "total_data_taking_percent": " 42.3",
        "instruments": {
            "AMO": {
                "runs": ,
                "runs_duration_sec": 0,
                "beam_status": ,
                "total_beam_time_sec": 0,
                "total_beam_time": "00 hr 00 min",
                "gaps": ,
                "gaps_duration_sec": 86400,
                "total_data_taking": "00 hr 00 min",
                "total_data_taking_percent": " 0.0"
            },
            "SXR": { … },
            "XPP": { … },
            "XCS": { … },
            "CXI": { … },
            "MEC": { … }
        },
        "systems": ,
        "status": "success"

    }

    I'm trying to extract the values under the "instruments" -> "AMO" hierarchy.  For example, the values for "total_beam_time" and "total_data_taking".  I need to store these extracted values in PLSQL variables.

    Can you please show me how to go about doing this?

    Thak you very much.

    Elie

     
  • James Sumners
    James Sumners
    2012-06-13

    declare
      my_json   json := json('{"foo":"bar","instruments":{"AMO":{"total_beam_time":"00 hr 00 min"}}}');
      beam_time varchar2(64);
    begin
      beam_time := json_ext.get_string(my_json, '["instruments"]["AMO"]["total_beam_time"]');

      dbms_output.put_line('Total beam time: ' || beam_time);
    end;
    /

     
  • Sunny
    Sunny
    2012-11-02

    sports in festival
    I like it but at the end its not a great deal