I need to parse the TLV data to JSON format.
Is there any library or any best way to parse/convert it to JSON?
Note: TLV --> Tag:length:value
Sample TLV:
ID;4;1578;NAME;7;TESTING;DESCRIPTION;10;Sample TLV;
Expected output:
{
ID:"1578",
NAME:"TESTING",
DESCRIPTION:"Sample TLV"
}
Related
I am parsing a JSON document using Java Jackson library. I have a situation in which the JSON document can contain a payload field in JSON/yaml/csv format. The parser is throwing exceptions; so I don't want the payload to be parsed. Is there a way I can delimit the payload so that it is considered as a string than structure?
Following is the json document: { "recordId":"48", "payLoad":{"firstName":"John","lastName":"Doe"} }
How can I delimit the payload content to be view as a String?
I am looking for a utility which converts one json format to another by respecting at the conversion definitions from a preferably xml file. Is there any library doing something like this in java ?
For example source json is:
{"name":"aa","surname":"bb","accounts":[{"accountid":10,"balance":100}]}
target json is :
{"owner":"aa-bb","accounts":[{"accountid":10,"balance":100}]}
sample config xml :
t.owner = s.name.concat("-").concat(surname)
t.accounts = t.accounts
Ps:Please dont post solutions for this example, it is just for giving an idea, there will be quite different scenarios in mapping.
Is this what u need?
Open input file.
Read / parse JSON from file using a JSON library.
Convert in-memory data structure to new structure.
Open output file
Unparse in-memory data structure to file using JSON library.
Is there any api or something to convert RSS feed to Json?
I used the api rss2json api with restTemplate, it's working fine when you map it with an entity but this one doesn't support multiple requests as it's gets overloaded plus there is no documentation for it or support so if the api goes down so is my app and I couldn't find something similar besides the rome plugin that converts to an object. I want direct conversion to Json.
I'm not sure what you mean by direct conversion to JSON, but you could simply use org.json to convert XML String to JSON String:
String xml = ..
JSONObject jObject = XML.toJSONObject(xml);
String json = jObject.toString();
More discussion here: Converting xml to json using jackson
I finished by using Rome plugin and built my own JSon structure step by step. no better solution so far.
I am looking for "transforming" (not plain-converting) XML(one data format) to JSON (to other/diff data format). Is there any tool/lib/framework to achieve this in Spring or Java?
Example
Input:
<root>
<element1>abc</element1>
<element2>xyz</element2>
.....
</root>
Output
{
"regionCode":"abc",
"regionName":"xyz"
...............
}
Thanks
Bharath
Please consider searching for your question. Have you considered camel? http://camel.apache.org/xmljson.html
What is the difference between "transform" and "convert"? Regardless, Jackson can read/write both JSON and XML (using the XML extension). You'll have to deserialize your XML into objects before serializing them as JSON but that's not a bad thing - it would be difficult to go directly from XML to JSON except in the most simple cases (JSON does not have attributes, for example).
I am trying to convert a java object within an ArrayList into both XML and JSON strings and then send it over to ActiveMQ server.
For converting to XML I am using XStream API and for converting to JSON I am using Google GSON API. I want to have consistent output after conversion in both the cases which I don't see here. One of them is showing the tag and the entire package name whereas the other one completely omits both.
Is there any standard conversion API available that I can use which actually converts the input object to a consistent output format for both XML and JSON?
Input Object (ArrayList containing some POJO):
==================
eventsLst = [PageViewEvent{pageName=Home Page, pageType=Home}]
XML Conversion (Using XStream):
====================================
<list>
<com.istore.event.model.PageViewEvent>
<pageName>Home Page</pageName>
<pageType>Home</pageType>
</com.istore.event.model.PageViewEvent>
</list>
JSON Conversion (Using GSON):
========================================
[{"pageName":"Home Page","pageType":"Home"}]