- Code: Select all
print(simplejson.dumps(entry_tp, sort_keys=True, indent=2 * ' '))
print(simplejson.dumps(entry_tp, sort_keys=True, indent=' '))
print(simplejson.dumps(entry_tp, sort_keys=True, indent=2'))
All but the last one results in an error in an Indigo scripting window (for example):
- Code: Select all
Script Error embedded script: can't multiply sequence by non-int of type 'str'
Script Error Exception Traceback (most recent call shown last):
embedded script, line 95, at top level
File "/Library/Application Support/Perceptive Automation/Indigo 7.4/IndigoPluginHost.app/Contents/Resources/PlugIns/simplejson/__init__.py", line 237, in dumps
**kw).encode(obj)
File "/Library/Application Support/Perceptive Automation/Indigo 7.4/IndigoPluginHost.app/Contents/Resources/PlugIns/simplejson/encoder.py", line 202, in encode
chunks = list(chunks)
File "/Library/Application Support/Perceptive Automation/Indigo 7.4/IndigoPluginHost.app/Contents/Resources/PlugIns/simplejson/encoder.py", line 426, in _iterencode
for chunk in _iterencode_dict(o, _current_indent_level):
File "/Library/Application Support/Perceptive Automation/Indigo 7.4/IndigoPluginHost.app/Contents/Resources/PlugIns/simplejson/encoder.py", line 344, in _iterencode_dict
newline_indent = '\n' + (' ' * (_indent * _current_indent_level))
TypeError: can't multiply sequence by non-int of type 'str'
This syntax runs error-free in Indigo:
- Code: Select all
indigo.server.log(simplejson.dumps(entry_tp, sort_keys=True, indent=2))