Hi Bruce, Glad you come up with Cobol2Json Converter. It is going to be very helpful. I am trying to see the examples on github and also tried to change Cobol to Json. But there was no luck. Most of the examples uses "dot bin " files and I don't know what is the use of that file. Is there a simple example that takes "dot cbl" file and change it to "dot json" file? I really appreciate that.
Here is my sample code.
Thanks Bruce, I was to mean to put the data file and the schema and convert to json.
Now I want to do exactly the reverse, change the JSON to Cobol format. I don't see any method in the Cobol2Json class. Does it do that? If so sample code that can convert Json back to Cobol?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
From the Screenshot you shared on wiki, it looks like the Cbl2Json converter is only one way? I see the Cbl2Xml and Cbl2Csv are two ways. Is that the case that I can't change Json back to Cobol with the new Cbl2Json Library? So what is better solution?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes Cbl2Json is one way converter (The others are 2 ways). I will have a look at what is involved in doing 2 wayin the next couple of days/ (from memory it was going to be harder than Xml). Not a lot of people use the Convert though.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Okay, I will try to use the cbl2xml by converting the json to xml and then to cbl. I have 0.90.2 (Cb2Xml and Jrecord)jar and I don't see the class Cobol2Xml, is there anything I missed?
I want to use use the
Cobol2Xml.newCobol2Xml ("sample.cbl")
.
.
.
.etc
.xml2Cobol("sample.xml", "sample.txt");
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Bruce,
Thanks you for maintaining this project.
I'm trying to write code that converts a copybook to a sample JSON based on your code (speciifcally, Cobol2JsonImpl.java). I managed to do it but I got NullPointerException from cb2xml, couldn't debug since I didn't find sources for the libs you used. Thereore I use newer versions (cb2xml-1.01.1 and JRecord-0.90.2) However, these new versions are significantly different, so I had to change your code. I changed
List<Item> items = cobolSchemaDetails.recordItems.stream().flatMap( ri -> ri.items.stream()).collect(toList());
And it works now for the files I tested, but I'm not sure it is the right thing to do. So my questions are:
1. Where can I get the sources for the libraries you used?
2. Conversly (and a better option for me), do you have a newer version of CobolToJson that uses newer versions of cb2xml-1.01.1 and JRecord-0.90.2?
3. Would like me to share with you my code of copybook-to-json-sample as a contribution?
Cheers
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Bruce, Glad you come up with Cobol2Json Converter. It is going to be very helpful. I am trying to see the examples on github and also tried to change Cobol to Json. But there was no luck. Most of the examples uses "dot bin " files and I don't know what is the use of that file. Is there a simple example that takes "dot cbl" file and change it to "dot json" file? I really appreciate that.
Here is my sample code.
It is giving me this output:
....Exception...null.
Is there anythign I missed?
Last edit: Bruce Martin 2020-09-12
I need the full stack trace but obvious errors are
I would expect
the Cobol Copybook (sample.cbl) describes the file and will look like:
The Data File (sample_data_file.txt) will have the raw data in the format described by the Copybook.
Finally the
Both have code generators for cblToJson. I will put together a Wiki for this in the next day or so.
I have created a Wiki on the RecordEditor/ReCsvEditor generate option
Thanks Bruce, I was to mean to put the data file and the schema and convert to json.
Now I want to do exactly the reverse, change the JSON to Cobol format. I don't see any method in the Cobol2Json class. Does it do that? If so sample code that can convert Json back to Cobol?
From the Screenshot you shared on wiki, it looks like the Cbl2Json converter is only one way? I see the Cbl2Xml and Cbl2Csv are two ways. Is that the case that I can't change Json back to Cobol with the new Cbl2Json Library? So what is better solution?
Yes Cbl2Json is one way converter (The others are 2 ways). I will have a look at what is involved in doing 2 wayin the next couple of days/ (from memory it was going to be harder than Xml). Not a lot of people use the Convert though.
Okay, I will try to use the cbl2xml by converting the json to xml and then to cbl. I have 0.90.2 (Cb2Xml and Jrecord)jar and I don't see the class Cobol2Xml, is there anything I missed?
I want to use use the
Cobol2Xml.newCobol2Xml ("sample.cbl")
.
.
.
.etc
.xml2Cobol("sample.xml", "sample.txt");
Hi Bruce,
Thanks you for maintaining this project.
I'm trying to write code that converts a copybook to a sample JSON based on your code (speciifcally, Cobol2JsonImpl.java). I managed to do it but I got NullPointerException from cb2xml, couldn't debug since I didn't find sources for the libs you used. Thereore I use newer versions (cb2xml-1.01.1 and JRecord-0.90.2) However, these new versions are significantly different, so I had to change your code. I changed
to
List<Item> items = cobolSchemaDetails.recordItems.stream().flatMap( ri -> ri.items.stream()).collect(toList());And it works now for the files I tested, but I'm not sure it is the right thing to do. So my questions are:
1. Where can I get the sources for the libraries you used?
2. Conversly (and a better option for me), do you have a newer version of CobolToJson that uses newer versions of cb2xml-1.01.1 and JRecord-0.90.2?
3. Would like me to share with you my code of copybook-to-json-sample as a contribution?
Cheers
The versions in Git-Hub should be fairly recent, I will yty to update them shortly
Do you mean you'd make CobolToJson work with the latest JRecord? That would be great!
Thanks for maintaining this project. It would be great if we can make CobolToJson two-way.
I will be releasing a new CobolToJson using the latest JRecord. I am currently updating cb2xml, CobolToCsv and will release them together.
I will have a look at JSon --> Cobol but it is not a high priority
Hi Bruce, any updates on the JSON schema --> cobol ?. Thank you
There is no JSON Schema --> Cobol Copybook
The latest version should do JSON_Data --> Cobol_Data (with a lot of limitations) e.g.
I have uploaded 0.90.4 version of cobol2json + JRecord should have the latest version of cobol2json