(json_data, extra_context=None, use_self=True)
return RecursiveExpand(json_data)
Recursively template-expand a json dict against itself or other context.

  The context for string expansion is the json dict itself by default, updated
  by extra_context, if supplied.

  Args:
    json_data: (dict) A JSON object where string values may be templates.
    extra_context: (dict) Additional context for template expansion.
    use_self: (bool) Whether to expand the template against itself, or only use
        extra_context.

  Returns:
    A dict where string template values have been expanded against
    the context.
Recursively template-expand a json dict against itself or other context.
Recursively template - expand a json dict against itself or other context .
def ExpandJsonTemplate(json_data, extra_context=None, use_self=True):
  """Recursively template-expand a json dict against itself or other context.

  The context for string expansion is the json dict itself by default, updated
  by extra_context, if supplied.

  Args:
    json_data: (dict) A JSON object where string values may be templates.
    extra_context: (dict) Additional context for template expansion.
    use_self: (bool) Whether to expand the template against itself, or only use
        extra_context.

  Returns:
    A dict where string template values have been expanded against
    the context.
  """
  if use_self:
    context = dict(json_data)
  else:
    context = {}
  if extra_context:
    context.update(extra_context)

  def RecursiveExpand(obj):
    # pylint: disable=missing-docstring, because the outer function is the doc.
    if isinstance(obj, list):
      return [RecursiveExpand(x) for x in obj]
    elif isinstance(obj, dict):
      return dict((k, RecursiveExpand(v)) for k, v in obj.items())
    elif sys.version_info[0] == 2 and isinstance(obj, (str, unicode)):
      return Template(obj).safe_substitute(context)
    elif sys.version_info[0] == 3 and isinstance(obj, str):
      return Template(obj).safe_substitute(context)
    else:
      return obj

  return RecursiveExpand(json_data)
def ExpandJsonTemplate ( json_data , extra_context = None , use_self = True ) : if use_self : context = dict ( json_data ) else : context = { } if extra_context : context . update ( extra_context ) def RecursiveExpand ( obj ) : # pylint: disable=missing-docstring, because the outer function is the doc. if isinstance ( obj , list ) : return [ RecursiveExpand ( x ) for x in obj ] elif isinstance ( obj , dict ) : return dict ( ( k , RecursiveExpand ( v ) ) for k , v in obj . items ( ) ) elif sys . version_info [ 0 ] == 2 and isinstance ( obj , ( str , unicode ) ) : return Template ( obj ) . safe_substitute ( context ) elif sys . version_info [ 0 ] == 3 and isinstance ( obj , str ) : return Template ( obj ) . safe_substitute ( context ) else : return obj return RecursiveExpand ( json_data )