CCD-102 practice question 4 of 30
A developer needs to update the package.json file so that it points to the hock file for a cartridge, using the hooks keyword. Which snippets work correctly when added to the file?:
Full set: 206 questionsTo register hooks in a Salesforce B2C Commerce cartridge, the package.json file must be updated. This file requires strict JSON syntax, meaning both keys and string values must be enclosed in double quotes. The hooks property points to the hook definition file. According to official Salesforce documentation, the value for the hooks key is a relative path from the cartridge's root directory (where package.json is located) to the hooks.json file. The standard location for this file is within the cartridge/scripts directory. Therefore, the correct path is ./cartridge/scripts/hooks.json. Option A is the only choice that uses both valid JSON syntax and the correct conventional path.
Salesforce B2C Commerce Developer Documentation
"Extend B2C Commerce with Hooks": This official guide specifies the method for registering hooks. It provides a direct example: "To register a hook
you add a hooks property to your cartridge’s package.json file. The value of the property is a path to a hook definition file
relative to the cartridge’s root directory. For example: { "hooks": "./cartridge/scripts/hooks.json" }". This confirms the syntax and path in option A. (Reference available in the B2C Commerce Infocenter).
JSON Standard (ECMA-404): The official JSON standard specifies that object keys (names) must be strings enclosed in double quotes. This rule invalidates options C and D. (See Section 4
"Objects").
Keep practicing
Take the free CCD-102 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other CCD-102 practice questions
- Question 1A developer has a sandbox with code to log a message during execution, and the following …
- Question 3Server.get(‘Show’, consentTracking.consent, cache.applyDefaultCache, function (req,res,ne…
- Question 5A developer wants to create in Business Manager extension with the cartridge named plugin…
- Question 6A client uses tax tables in Business Manager to calculate tax. They recently started ship…
- Question 7A Digital Developer has a site export file on their computer that needs to be imported in…
- Question 8The developer created a new Storefront category in storefront-catalog-m-en, but when view…
