First I want to say I checked this nice question:
JSON to JSON transformer
I want to do something similar, however, I would like to know if there is a solution that will generate the transformation automatically, knowing I have an Input.json and a Output.json sample available at hand.
So I would give the program both json (input, output) and it generate for me the JsonPatch transformations that were done so that input + transformation = output.
Maybe this tool does not exist, but it would save me a lot of time! In java would also be a big plus :)
Related
Want to create a tabular report from Java using JSON file. I have an 861 kb Json report with me.
Kindly suggest me the approach need to be followed.
It sounds like your input is JSON. You did not specify an output format. But similar as in HTML you could place tabular data into JSON as well. Assuming that is the case, all you need is a JSON parser/serializer and inbetween some Java code to adapt one format for the other.
To transfer one XML data structure into another XML data structure there are nice tools like XSLT. Some of the implementations can also be used for JSON documents. See https://stackoverflow.com/a/49011455/4222206
With the above assumption your code would perform these steps:
Parse input JSON
Run XSLT for JSON
Serialize the obtained output
I wanted to parse x12 format file to json file using java.
I didn't find any information regarding this on internet.
can someone please tell me how to do this or any jar file which can be able to do this is also fine.
How to do it:
Obtain documentation on your x12 file (do you mean HIPAA data exchange?). It will tell you about the different records, their layout and sequencing
Define target schema for the JSON you want to produce. Surely you don't want to produce just any JSON
Define mapping. Draw spaghetti on a whiteboard, piece of paper, or something like Altova Mapforce, until you have all elements connected.
Choose your transformation approach depending on the dataset size - streaming or object to JSON serialization
Implement
Look for performance bottlenecks. Introduce optimizations to speed up processing.
I am attempting to parse a KML file which has some non-standard tags:
<Placemark id="plot">
<Type1> Type 1 </Type1>
<SA>62</SA>
<Type2> Type 2 </Type2>
I'm attempting to read/parse the file, obtain the representative elements as described above and then all the coordinates, and finally write the output to a text file for downstream use. I'm able to parse the file and get the coordinates with no issues but have been unable to determine a way to get the custom elements, and I need the data to format the output file correctly. The elements are not wrapped in an extendeddata structure or any other grouping.
I am hoping someone has run into this before and can offer some guidance on the best way to read the data via supplied methods for javaapiforkml.
You can have a look at OSMBonusPack KML parser, mainly here.
It's open source, so you can pick the classes you need, remove all Android-specific features, and add handling for your custom tags.
I am trying to figure out a way to produce test execution charts from cucumber produced JSON.
I looked into JFreeChart and would like to know if there a way to use JSON as input for JFreeChart or other java library.
JFreeChart won't read your JSON format data out-of-the-box, so you'll need to write your own code to process the JSON file/string and populate a dataset accordingly. I did something like this recently for Orson Charts, and used json-simple to do the JSON parsing. Of course, the code I wrote parses only a very specific set of JSON formats. I don't know the details of the "cucumber produced json" that you need to process, but hopefully the json-simple project can help you to get it done.
I need to both parse incoming messages and generate outgoing messages in EDIFACT format (basically a structured delimited format).
I would like to have a Java model that will be generated by parsing a message. Then I would like to use the same model to create an instance and generate a message.
The first half is fine, I've used ANTLR before to go from raw -> Java objects. But I've never done the reverse, or if I have it's been custom.
Does ANTLR support generating using a grammar or is it really just a parse-only tool?
EDIT:
Expansion - I want to define two things ideally. A grammar that describes the raw message (EDIFACT in this case but pretend it's CSV if you like). And a Java object model.
I know I can write an ANTLR grammar to get from the raw -> Java model. e.g. Parsing a SQL string -> Java model which I've done before. But I need to go the other way as well ideally without changing the grammar.
If you liken it to JAXB (XML world), I really want JAXB for EDIFACT (rather than XML).
Can ANTLR do what you are asking, YES. Although it might require multiple grammers.
To me, this sounds like you want to create a AST from your parser. Have one tree walker doing all the java object creation required (second grammer possibly). And then a second tree walker to create the output messages (third grammer), and you can even use StringTemplate if you want. Maybe you can get away with two grammers.
But at this point actual details would have to be given for any more help, what the AST will look like for a specific input and what the output message should be.
I have never done it myself (I also used ANTLR for parsing only) but I know for sure that ANRLR can be used as a generator as well.
in fact, it's using a library called stringtemplates for it's own code generation (by the same author).