How to convert Json data directly into xml - standardized way?
The Serializer component is a tool in your Drupal toolbox that should be used when you need to serialize and deserialize data from and to Drupal data such as entities. Unfortunately you cannot deserialize into a \StdClass without implementing your own normalizer.

Inject the serializer service into your class, and use the serialize method to normalize the non-Drupal decoded JSON array into XML.

// Inject this instead of using \Drupal
$serializer = \Drupal::get('serializer');
// Use json_decode or @4k4's example above and use associative arrays instead of object.
$json = json_decode('[{"S":"a","D":"b"},{"S":"s1","D":"m1"},{"S":"2","D":"3"},{"S":"4","D":"5"}]', TRUE);
// Unfortunately it seems that for an array serializer xml_root_node_name won't work so wrap $json in the root name.
$data = ['US' =&gt; $json];
// Serialize into XML.
$xml = $serializer-&gt;serialize(
  $data,
  'xml',
  ['xml_root_node_name' =&gt; 'US']);