My goal is to retrieve data through AJAX without formatting it as JSON, so I took the initiative to encode it myself.
The data I am working with consists of client records: where the pound sign (#
) separates the client records, the pipe sign (|
) separates the fields within each record, and the carat sign (^
) distinguishes the field name from its corresponding value.
This is a simplified representation of the data:
name^James|email^<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ff8c90929a929e9693bf98929e9693d19c9092">[email protected]</a>#name^Bary|email^<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="583a392a21183a392a21763b3735">[email protected]</a>#...
Upon loading this data into Javascript, my objective is to format it into a 2-dimensional array similar to this:
clients = [
['name'=>'James','email'=>'<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="61120e0c040c00080d21060c00080d4f020e0c">[email protected]</a>'],
['name'=>'Bary','email'=><a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="bedcdfccc7fedcdfccc790ddd1d3">[email protected]</a>]
]
Alternatively, an object format could also be considered. What would be the most effective method to accomplish this?