Skip to content

Rule.io SDK


Rule.io SDK / rcml/src / jsonToSmsRfm

Function: jsonToSmsRfm()

jsonToSmsRfm(json): string

Defined in: rcml/src/sms/json-to-sms-rfm.ts:29

Convert an SmsContentJson document back to an SMS RFM string.

Reverse of smsRfmToJson. The conversion is lossless:

  • Text nodes with a link mark → :link[text]{href="..." track="..." shorten="..."}
  • Placeholder nodes with a resolved value or max-length → ::placeholder{...} directive form
  • Placeholder nodes with null value and null max-length → compact [Type:Name] form
  • Hardbreaks → \ at line end
  • Paragraphs → separated by \n\n

Parameters

json

SmsContentJson

Typed SMS content JSON ({ type: 'doc', content: [...] }).

Returns

string

SMS RFM string.

Example

ts
const json = smsRfmToJson('Hello [Subscriber:FirstName]')
const rfm = jsonToSmsRfm(json)
// rfm === 'Hello [Subscriber:FirstName]'