Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions httpie/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,17 @@ def _split_lines(self, text, width):
).rstrip(),
)
)
output_processing.add_argument(
'--xssi', '-x',
dest='xssi_prefix',
metavar='PREFIX',
default='',
help="""
(default) Assumes incoming JSON has no XSSI Prefix
Allows Specifying a particular XSSI Prefix for the incoming JSON.

"""
)


#######################################################################
Expand Down
3 changes: 3 additions & 0 deletions httpie/output/formatters/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ def format_body(self, body, mime):
]
if (self.kwargs['explicit_json'] or
any(token in mime for token in maybe_json)):
xssi_prefix = self.kwargs["xssi_prefix"]
if xssi_prefix and body.startswith(xssi_prefix):
body = body[len(xssi_prefix):]
try:
obj = json.loads(body)
except ValueError:
Expand Down
1 change: 1 addition & 0 deletions httpie/output/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def get_stream_type(env, args):
groups=args.prettify,
color_scheme=args.style,
explicit_json=args.json,
xssi_prefix=args.xssi_prefix
),
)
else:
Expand Down