Display list content from other URL In HTML using JS - javascript

I am trying to do a simple task; retrieve JSON using Jquery and display the name to a simple HTML list, usually, the JSON file I deal with is quite straightforward with a format of
[ {a:1,b:2},{a:3,b:4}]
, but this time, the file (hosted on a different website) has a format similar to
[
["John",21,5,"description","some-link"],["Doe",3,6,"description","some-link"],]
with another 100k entries. My goal is to simply display all the names of this file in an HTML list.
Is there a way to retrieve the list and display content such as the name and description in simple HTML ul?
the actual file link is here: https://www.dropbox.com/s/104iutbz95o7wtw/test.json?dl=0 (consider it is actually hosted on a website for example: https://sample.com/test.json)

You need a regex to return a list of the data.
Have a look at this one I made for you: https://regex101.com/r/aDRp6A/1
It would help to know if the data has a strict structure or if it's variable.
EDIT:
Given your sample data I can see yours is just a list of lists. No curly brackets. That's good!
Once you have your json as a string try to split it:
myList = yourJsonObject;
And then you can access the data with:
myList[0][0]

hello you need to build your own parser or use regex, because the format that you mention is not JSON

Related

How to retrieve data from HTM file and convert to json using <input file> in Javascript (Vue)

I'm trying to upload a HTM file using in Vue. The data is actually a styled table using , , etc...
My question is that, is it possible to filter out the tabulated data in HTM into other forms of data, say JSON? - Picture below (taken from browser elements of the htm) - Basically I just want to filter out html syntaxes and just retrieve the data.
Solution: use RegEx to filter HTML syntaxes.
Similar post:
Regular expression to remove HTML tags from a string

How do I store data in a json file?

For a class project we have to build an online store in 3 parts: html, css and js, the first 2 are done but i'm at a loss about js! We should be able to put the info of one product in a json file, and parse it in html. but tbh i'm not even sure how or where to begin with it, any suggestions are appreciated! Thanks!
First you can start by creating your JSON file that has all the information about the store that you want, then you can use JavaScript to read the data in that file. Finally you can use HTML and some binding to parse and show whatever you want. I can help you out if you post some sample code or a jsfiddle.

Javascript - Read file and compare content

I'm having a file which contains a couple of space separated (or comma separated, it will be editable) serial-numbers (all unique).
Now through my Oracle APEX I get one serial-number. My goal is to check if this serial code which could be passed on to a parameter of obtained through $v('P#_SERIAL_ID') is equal to one of the serial-numbers in the file.
Is this even possible within Javascript? If so, is there an existing function/code to achieve my goal?
Stackoverflow questions that didn't help me but look alike:
Javascript-read-file-contents
C#-reading-and-editing-file
Java-string-comparison
You can do this without JavaScript. Import your file into Apex through an Data Load Wizard Page so you will have the content of your file into a table. This way you can compare your information through some kind of SQL validation.
If you don`t like the Data Load Wizard Page you can add a file browse item on a simple page that will take your file and save it as a blob into the database. From there you can again process the file and compare the values.

Creating JSON object from text file values

I want to convert the plaintext Public Suffix List to JSON object so as to use it in my script. I just want the list of TLD's.
The list is here https://publicsuffix.org/list/effective_tld_names.dat
My initial thought was to regex match the file for suffix list but I don't know how to regex files in javascript. I'm kind of new to javascript.
Anyone having idea, how to achieve this. Thank You
First off, the list doesn't seem to be allowed to do cross-domain, so direct AJAX to the resource isn't possible.
What you can do is have your server load it for you (PHP: file_get_contents, JS: http.get). Then, implement a parser. I'm not familiar with the format of the file, but you can read the file line by line, skip blank lines and lines with //. Then load them into an array (PHP: array_push, JS: Array.prototype.push), serialize (PHP: json_encode, JS: JSON.serialize) and ship as JSON to your app.

How to append external JSON in plain HTML?

I'm trying to output some values taken from an API (JSON-formatted). And can't find a solution on how to grab the JSON tags and make them turn into HTML. JSON example here.
How do I get that JSON to turn out as DIV-tags, paragraphs and headings?
you need to code that. there are already existing libraries who can help you there: http://json2html.com/
There's no 1-to-1 mapping between JSON and HTML. You will have to do that manually depending on the JSON structure. So for example you could access inidividual elements of your object like this:
result.glossary.GlossDiv.GlossList.GlossEntry.ID

Categories