Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.

srp_jsonX

Are there any helpful conversion rules for converting this html to json.
I have done a few so far and can second guess it, but not sure if doing it correctly.

<div data-role="collapsible-set"> <form name="wtk_search" id="wtk_search" action="/%SITEID%/%GATEWAY%/%PROCEDURE%?method=%METHOD%" method="post"> <div data-role="collapsible" data-collapsed="true"> <h3>Job - {JOB_NO} - {JOB_NAME}</h3> <label for="job_no">Job No:</label> <input type="text" id="job_no" name="job_no" readonly="readonly" value="{JOB_NO}"></input> <label for="job_name">Job Name:</label> <input type="text" id="job_name" id="job_name" readonly="readonly" value="{JOB_NAME}"></input> </div> <div data-role="collapsible" data-collapsed="true"> <h3>Customer Details - {CUST_NAME}</h3> <label for="customer">Customer:</label> <input type="text" id="customer" name="customer" readonly="readonly" value="{CUST_NO} - {CUST_NAME}"></input> <label for="customeraddress">Address:</label> <input type="text" id="customeraddress" name="customeraddress" readonly="readonly" value="{CUST_ADDRESS}"></input> <label for="customerphone">Phone:</label> <input type="text" id="customerphone" name="customerphone" readonly="readonly" value="{CUST_PHONE}"></input> <label for="customerfax">Fax:</label> <input type="text" id="customerfax" name="customerfax" readonly="readonly" value="" ></input> </div> <div data-role="collapsible" data-collapsed="true"> <h3>Site Details - {SITE_COMPANY}</h3> <label for="sitecompany">Site Company:</label> <input type="text" id="sitecompany" name="sitecompany" readonly="readonly" value="{SITE_COMPANY}"></input> <label for="siteaddress">Site Address:</label> <input type="text" id="siteaddress" name="siteaddress" readonly="readonly" value="{SITE_ADDRESS} {SITE_CITY} {SITE_POSTCODE}"></input> <label for="sitecontact">Site Contact:</label> <input type="text" id="sitecontact" name="sitecontact" readonly="readonly" value="{SITE_CONTACT_NAME} M:{CONTACT_COY_PHONE} Ph:{CONTACT_COY_PHONE}"></input> <a id=sitemap" href="http://maps.google.com/maps?q={SITE_ADDRESS}+{SITE_CITY}+{SITE_POSTCODE}" data-role="button" target="_blank">Map</a> </div> <div data-role="collapsible" data-collapsed="true"> <h3>Job Details</h3> <!--<label for="job_details">Job Details:</label>--> <!--<textarea type="text" id="job_details" name="job_details" cols="40" rows="8">{ITEM_DESC}</textarea>--> <p style="white-space: pre-wrap">{ITEM_DESC}</p> </div> <div data-role="collapsible" data-collapsed="true"> <h3>Attachments <span class="ui-li-count">[{ATTACHMENTS_COUNT}]</span> </h3> {ATTACHMENTS_UL} </div> <div data-role="collapsible" data-collapsed="false"> <h3>Works Completed</h3> <label for="new_job_details">Works Completed:</label> <textarea type="text" id="new_job_details" name="new_job_details" cols="40" rows="8"></textarea> <button type="submit">Update Job</button> </div> </form> </div>

Comments

  • There are no rules for this. HTML is more about formatting content for rendering in a browser whereas JSON is more about formatting content for sharing between systems. There is no one-to-one correspondence between the two. I suggest taking the path of least resistance and parse out the actual data and generate a JSON structure that makes the most sense from a semantic point of view rather than try to create some kind of structure that attempts to mimic the HTML.
  • Cool, that's what I have been doing.
    Thanks.
    I am using the 'href' label for any '_links' and '_form' at the head - the potential web developer hasn't seen it, so, may need to adjust to suit their 'needs' when finally completed.
  • Let's hope the potential web developer appreciates and utilizes the links. The true meaning of REST is in those links, but most people think of REST as just APIs that return JSON content.
Sign In or Register to comment.