Import json data

is it possible with visual to Import json-data/files simply?

Or must we have separate Tools?

have MF a Little examples in Cobol?

thanks for each help!

  • Can you please provide some more detail as to what you wish to do with the JSON files? If you wish to access a RESTful Web Service using JSON then the Interface Mapping Toolkit (IMTK) can generate a COBOL client from a JSON schema file that will consume the Web Service. Which Visual COBOL product are you using, VC Visual Studio, Eclipse or DevHub?
  • I just have developed a small WPF-Program reading a JSON file and displaying some filed in a DataGrid. I send it to Claude Greiner.
  • You could make it available to the community. I also have an interest in this subject. Thank you!
  • *> Author: Werner Lanter (
    class-id JSON.Window1 is partial
    inherits type System.Windows.Window.

    working-storage section.
    method-id NEW.
    procedure division.
    invoke self::InitializeComponent()
    end method.

    method-id PBLaden_Click.

    01 StrReader type System.IO.StreamReader.
    01 jsonstring string.

    01 restaurants type Restaurants.
    01 restaurant type Restaurant.

    01 SeqNr binary-long.

    01 JavaScriptSer type System.Web.Script.Serialization.JavaScriptSerializer.

    procedure division using by value sender as object e as type System.Windows.RoutedEventArgs.

    *> Test File existsts
    if not type System.IO.File::Exists(F_Filename::Text)
    set tbGelesen::Text to "File not found"
    exit method

    *> Read File into JSON String
    set StrReader to new System.IO.StreamReader(F_Filename::Text)
    set jsonstring to "{""Restaurants"":" & StrReader::ReadToEnd() & "}" *> Top Node missing in File

    *> Deserialize JSON String into Objects
    set JavaScriptSer to new System.Web.Script.Serialization.JavaScriptSerializer().
    set restaurants to JavaScriptSer::Deserialize[type Restaurants](jsonstring).

    *> Display Number of Restaurants in TextBlock
    set tbGelesen::Text to "Anzahl Restaurants: " & restaurants::Restaurants::Count::ToString()

    *> Set Sequence Number for Restaurants
    move 0 to SeqNr
    perform varying restaurant thru restaurants::Restaurants
    add 1 to SeqNr
    set restaurant::SeqNr to SeqNr

    *> Set Restaurant-List as ItemsSource of DataGrid
    set RestaurantGrid::ItemsSource to restaurants::Restaurants.

    end method.

    method-id PBSchliessen_Click.
    procedure division using by value sender as object e as type System.Windows.RoutedEventArgs.

    invoke self::Close().

    end method.

    end class.

    class-id Restaurants.

    working-storage section.

    01 ws-Restausrants type System.Collections.Generic.List [type Restaurant] property as "Restaurants".

    end class.

    class-id Restaurant.

    working-storage section.

    01 w-SeqNr binary-long property as "SeqNr".
    01 property1 string property as "Enseigne".
    01 property2 string property as "Nom_du_restaurant".
    01 property3 string property as "FR".
    01 property4 string property as "Nom_Exploitant_1".
    01 property5 string property as "Ville_Resto".
    01 property5b type DateTime property as "Ouverture".
    01 property6 string property as "TVA_intracom".
    01 property7 string property as "Horaire_Drive_Lundi".
    01 property8 string property as "URL_Page_locale".

    end class.
  • Vielen Dank Herr Lanter dass Sie ihre Erfahrungen der Community zur Verfügung stellen, dies müsste noch viel mehr gemacht werden, um anderen Entwickler zu helfen / Thank you Mr Lanter to give your experience to the community! We must to this more and more to help other programmers