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

Close

Newbee Question - building up list from objs

2012-04-10
2013-05-28
  • Hi,
    I am trying to build a json_list from objects created while looping in a cursor.  All of the examples hard code the array values.  Can you give me an example?

    inside my cursor loop it looks like this:
    j_inner_obj := json();
    j_inner_obj.put('lastName', row_search.family_name);
    j_inner_obj.put('firstName', row_search.given_name);

    • I tried  
      l_obj.append(j_inner_obj);  - where l_obj is an json_list() and j_inner_obj is a json()

    but this did not work.

    Thank you in advance

     
  • James Sumners
    James Sumners
    2012-04-10

    Here is an anonymous block example:

    declare
      js_list json_list := json_list();
      js_obj  json;
    begin
      for i in 1..10
      loop
        js_obj := json();
        js_obj.put('obj_' || i, 'value_' || i);
        js_list.append(js_obj.to_json_value);
      end loop;
      
      js_list.print;
    end;
    /
    
     
  • Thanks -
    js_list.append(js_obj.to_json_value)  - was the missing ingredient