I trying to convert some HTML string to JSON string and then to objects, to store any images data on some page to TXT file.
I used Curl to download the page data (and can use nlohmann/json to convert JSON strings to object)
Now I need some way to convert HTML String to JSON Objects or find a way to convert the relevant for me data (like and tags)
Thanks for help
Related
I've found a lot of solutions that use on-the-fly scripting to convert JSON and JSON-Schema's to a human-readable form.
What I need, however, is a way to produce the raw HTML without any dynamic elements on the server side.
This form will need to be a read-only HTML view of the JSON object.
Options#1:
Take a JSON-Schema and convert it to a pure HTML template.
Store the pre-generated HTML Template.
Then, for each JSON I pass it and the template to a method (maybe w/ some css).
And finally get raw HTML.
Option#2:
Store the JSON-Schema.
Pass the JSON-Schema and the raw JSON to a method (maybe w/ some css).
And finally get raw HTML.
What will be the preferred way of converting JSON to XML file? Is it better to use web-service or any Java component? I tried using web-service and still wanted to cross-check if there is any other option to do this.
Convert JSON text contained in string json into an XML node
XmlDocument Xmldoc = JsonConvert.DeserializeXmlNode(json);
Here is the documentation:
Json to xml
I have a js file which is in json format and i want to convert this file to a human readable format.Is there any external software which does that or i have to code it??Am new to this stuff.
Json is a format which looks like plain text. I guess you know what you are asking. If you need to convert a file containing Json text to a readable format, you need to convert that to an Object and implement toString() method(assuming converting to Java object) to print or write to another file in a much readabe format. You can use any Json API for this, for example Jackson JSON API.
ObjectMapper obj = new ObjectMapper();
T t=obj.readValue(File src, Class<T> valueType)
t.toString(); //this must have been implemented
I've been trying for a while to get a byte[] from my database blob and then parse it to json and send it to my clients. I first get the blob from the database and then I get the byte array by doing:
MyObject temp = new MyObject()
Blob icon = dbResult.getBlob(1);
temp.setIcon(icon.getBytes(1, (int)icon.length()));
Later on I parse MyObject to a json string which I send back to clients. But it seems that the json string becomes pretty much corrupted when parsing the byte[].
An example of how it might look:
[{"icon":"/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAFQAPwDASIAAhEBAxEB/8QAHAAAAQUBAQEAAAAAAAAAAAAAAgEDBAUGAAcI
I parsed this to json in my webservice which is a jersery webservice. When i try to parse it from json into a class object at client side, it throws IllegalStateException(Gson).
Anyone knows what this is about and what i'm doing wrong?
If you try to transfer binary data using json, you better explicitly encode it with base64 and then decode it on receiver's side. JSON isn't designed to wrap binaries, so the problems when trying to make this were expectable.
i hav one problem , i parsed xml using json parsing and get json text. now i have to get values from xml. from that json text how i can identify jsonObject, jsonArray etc...
If you're doing this with JavaScript in a browser, try parsing the XML using jQuery.