DXA JSON 2 – Honey we shrunk the JSON

June 5th, 2018 | Posted by Robert Curlette in DXA

DXA 2 promises to publish less verbose JSON, sending smaller JSON items into the Publishing Queue and therefore speeding up our publish times.  It will also consume less space in the Broker DB.  So they say!  But, what does the new and old JSON look like and is it much lighter?  In this article I’ll highlight only the diffs between the rendering of a Keyword field JSON and Textfield JSON.  And, you might be wondering why I even care (aside from curiosity), but I’ve built a TBB that amends the Published DXA JSON and injects Structure Group Metadata fields masquerading as Page Metadata fields (in the JSON) and therefore available to our DXA Frontend WebApp.  OK, so here it is:

DXA 1.7 Keyword Field

"people": {
 "Name": "people",
 "Values": [ "Public and Member Communications", "Public Interest people", "Publications and Databases" ],
 "NumericValues": [ ],
 "DateTimeValues": [ ],
 "LinkedComponentValues": [ ],
 "FieldType": 3,
 "CategoryName": "people List",
 "CategoryId": "tcm:11-11393-512",
 "XPath": "Metadata/custom:people",
 "KeywordValues": [
 {
 "IsRoot": false,
 "IsAbstract": false,
 "Description": "",
 "Key": "",
 "TaxonomyId": "tcm:11-11393-512",
 "Path": "\\people List\\Public and Member Communications",
 "RelatedKeywords": [ ],
 "ParentKeywords": [ ],
 "MetadataFields": { },
 "Id": "tcm:11-106852-1024",
 "Title": "Public and Member Communications"
 },
 {
 "IsRoot": false,
 "IsAbstract": false,
 "Description": "",
 "Key": "",
 "TaxonomyId": "tcm:11-11393-512",
 "Path": "\\people List\\Public Interest people",
 "RelatedKeywords": [ ],
 "ParentKeywords": [ ],
 "MetadataFields": { },
 "Id": "tcm:11-106848-1024",
 "Title": "Public Interest people"
 },
 {
 "IsRoot": false,
 "IsAbstract": false,
 "Description": "",
 "Key": "",
 "TaxonomyId": "tcm:11-11393-512",
 "Path": "\\people List\\Publications and Databases",
 "RelatedKeywords": [ ],
 "ParentKeywords": [ ],
 "MetadataFields": { },
 "Id": "tcm:11-106853-1024",
 "Title": "Publications and Databases"
 }
 ]
}

DXA 2.0 Keyword Field

"people": {
 "$type": "KeywordModelData[]",
 "$values": [
 {
 "Id": "106852"
 },
 {
 "Id": "106848"
 },
 {
 "Id": "106853"
 }
 ]
},

DXA 1.7 Text Field

"language": {
 "Name": "language",
 "Values": [ "English" ],
 "NumericValues": [ ],
 "DateTimeValues": [ ],
 "LinkedComponentValues": [ ],
 "FieldType": 0,
 "XPath": "Metadata/custom:language",
 "KeywordValues": [ ]
},

DXA 2.0 Text Field

"language": "English",

Summary

So, there we have it, the new DXA 2.0 JSON delivers what it promises – much leaner and meaner JSON for the benefit of us all.

You can follow any responses to this entry through the RSS 2.0 You can leave a response, or trackback.

One Response

  • Rick Pannekoek says:

    Thanks Robert; it’s nice to see others proving our point!

    Note that you immediately demonstrated another feature of DXA 2.0: “Dynamic Keyword Expansion”.

    That is: you see that the Keyword field values have been shrunk all the way back to only the (numeric) IDs of the Keywords. You may think: “hey, but that’s too far! I need the Keyword properties in my Web Application”. Don’t worry: you will be able to do that.

    DXA 2.0 TBBs shrink Keyword data down all the way to Id (and SchemaId) only if the Category is publishable. In that case, the DXA Model Service will expand the Keyword data dynamically, so your Web Application still gets all the data you need. DXA 2.0 can do a similar thing for linked Components.

    See also: https://tridion.stackexchange.com/questions/18919/keyword-information-not-populated



Leave a Reply

Your email address will not be published. Required fields are marked *