schema.org json-ld using coldfusion - json

I have not used json with coldfusion hence looking for some advice. I am trying to use coldfusion to get the schema.org json-ld work on a website. I have a query coming from a component which has the data that needs to go in the json. Can someone give me a gist of what needs to be done in order to spit out the json from the query in the below script tags on the page. Thanks in advance.
<script type="application/ld+json"></script>

I used this JSON-LD Schema Markup Generator to determine the fields and schema to use and then created a ColdFusion struct that matched it. For some elements (addresses, social media URLs, multiple locations), you'll need to create an array-of-structs.
There are many optional parameters you can add to each markup type, so it's difficult to program a one-size-fits-all solution. (I finally managed to write a custom tag that works specifically with our internal/custom CMS to auto-generate this for our client webpages.)
Here's a bare-bones ColdFusion sample for type "WebSite". (We've been adding inlining the JSON to the same webpage.)
<cfscript>
SchemaData = {
"#context" = "http://www.schema.org",
"#type" = "WebSite",
"name" = "My Website",
"alternateName" = "My Alternate Website Title (optional)",
"url" = "https://www.mywebsite.com/"
};
writeoutput('<script type="application/ld+json">#SchemaData#</script>');
</cfscript>

Related

`versions:batch-get` doesn't fetch the "Title" Custom Attribute

I've been trying to get the "Title" attribute of documents within my projects' Plans folder, but the sheets number/displayName appears in the title field of the response:
{
"urn": "urn:adsk.wipprod:fs.file:[...]version=1",
"itemUrn": "urn:adsk.wipprod:dm.lineage:[...]",
"name": "A13.3",
"title": "A13.3", // <- Here
"...": "...",
"customAttributes": [], // <- Nothing here, even if I modify the "Title value"
"number": "A13.3"
}
Is this intentional? Or have I misunderstood? I can't find any other endpoint which has documentation suggesting it'll fetch the Title attribute. I see that the BIM360 web app is using the legacy endpoint to fetch this property for itself:
projects/:project_id/folders/:folder_id/custom_attributes.
I know this is similar to a previous question, but it seems that was asked well over a year ago when there was no versions:batch-get endpoint.
Thank you in advance!
The documentation you mentioned is out-of-date. Please check this one instead:
https://forge.autodesk.com/en/docs/bim360/v1/reference/http/document-management-versionsbatch-get-POST
The fields like title, displayName and name are Docs built-in custom attributes and will appear in response of POST versions:batch-get only, not in GET custom-attribute-definitions.
Besides, the customAttributes field of POST versions:batch-get and GET custom-attribute-definitions are for user-created custom attributes only. If you don't assign any value to your user-created custom attributes to either the document or file of your Docs project, then customAttributes field will be empty. Here is the field description from the documentation.
The list of custom attributes for each document. For more information about custom attributes, see the Customize Documents with Attributes documentation.

Gatling HTML response

Below is my HTML response in Gatling. I am looking to extract the value of the url field. How do I do that?
script type="text/javascript" id="test">
var initialVars={ "context" : { "A": "XXXX", "B":"XXXXX"}, "u.d" : {"C":"ABC", "D":"FGH"}};
var z = {"desktop": {"Q": "12345"}, "q.d": {"F": "QQQ", "url": "A&B=345=hhh"}}
I'm afraid you'll have no choice but to use regular expressions here. HTML parsers such as Gatling's CSS selectors support won't be of any help as you're trying to capture some data in inlined JavaScript.
Then, your problem has nothing to do with being new to Scala or Gatling.
It's about using/learning Java regular expressions.
If you struggle, you should read the Java patterns documentation and try some online evaluator.
Once you have your regex figured out, use it to add a regex check in your Gatling test.
Thank you! I figured out most of it.. This is the part that I am trying to extract
transId=7a2cd0ada80a8285cd1234d144631e80&pzFromFrame
Following REGEX expression ([0-9]+[a-z]+) extracts 7a2cd0ada80a8285cd1234d144631e leaving 80. How to extract 7a2cd0ada80a8285cd1234d144631e80?

How to render content of wordpress api?

I am creating a mobile app for a wordpress solution, while studying wordpress rest api, I have found a problem with the way the json schema is rendered;
while /wp-json/wp/v2/posts displays all posts but it is in this format
"title": {
"rendered": "testing rest api & #8220;tesint-restAP& #8221;"
},
How to extract the actual content from response.data.content because it came as html version with tags and such ???.
Tip for .NET Developers
When using http://restsharp.org/ in .NET to call the API, no parsing was required on the content.
First, get your json data with its html tags, then
var StrippedString = OriginalString.replace(/(<([^>]+)>)/ig,"");
Just use content of "rendered" as value for innterHTML property of element like div. It will work.
let htmlStr = `<p><em>“Anatomy of a Bear Market”</em> by Russell Napier is a <em>“must-read</em>” manuscript. Given current market dynamics, a review seems timely. As my colleague, Richard Rosso, CFP, previously penned:</p>`
let ele = document.getElementById('target');
ele.innerHTML = htmlStr;
<div id="target"></div>

Creating a UI/writing HTML from a JSON file

I have a really long, unwieldy, unformatted JSON file generated by Lighthouse (a tool that conducts page load time analysis- so this file has the results of the tests). In order to make it formatted to be readable by people, I need to apparently create a UI around this file. My problem is that I'm not sure how to begin working on it.
I've read about something like creating HTML from JSON objects, I think I'd like to try that to just display all the information from the tests in the browser right now... But where would I write that? I have one Node.js file right now, which is running the tests and using JSON.stringify() to stick the JSON'd results into a file. Can I generate the HTML right after I create the JSON? (And the main question- how would I create HTML from a JSON file?)
I'm just starting out with Node and JSON, any tips are highly appreciated.
Yes, you can create HTML from a JSON file.
Here's a simple example done with jQuery, first creating an array of all of the elements, and then using .join("") to parse them. Once parse, they can simply be appended anywhere in the DOM:
var json_file = {
"one": "Hi there",
"two": "Another item",
"three": "Third item"
}
var items = [];
$.each(json_file, function(key, val) {
items.push("<li id='" + key + "'>" + val + "</li>");
});
$("<ul/>", {
"class": "json-list",
html: items.join("")
}).appendTo("body");
// Sample extension showcasing manipulation of inserted HTML
$(".json-list #two").css('color', 'red');
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
Obviously, the more complicated your JSON (and desired HTML structure), the more complicated the method of parsing the JSON is going to be.
A templating engine would make your job significantly easier,
and there and hunderds of these. Some of the more popular ones are:
EJS
jQuery.dForm
JQuote2
JSON Template
JTemplates
Mustache
PURE
Tempo
Hope this helps! :)

Generate page url rather than data id with JSON in Umbraco

(Please bare in mind that I am new to Umbraco and JSON!)
In Umbraco, I'm looking to use JSON (alongside HTML and CSS) to turn grid cells into buttons. So far I've accomplished this using the below code (generated from an amalgamation of different tutorials/guides), but this is generating urls which end with the numerical data-id of the page. E.g. www.mywebsite.com/0000/. This works as a link and goes to the correct place, but I'd much rather it generated a URL with the correct name? I.e. something more like www.mywebsite.com/page-name/.
How can this be done?
{
"label": "destination",
"description": "Choose destination",
"view": "treepicker",
"key": "class=\"button\"><a class=\"buttonLink\" href",
"applyTo": "cell"
}
]
If you are using Umbraco, then you can easily get the URL or URlName of the page you are on.
IPublishedContent has all these properties and you can inherit this interface to your class to access these.
Thanks