pytest-html icon indicating copy to clipboard operation
pytest-html copied to clipboard

any method to auto format the extra json?

Open LeiYangGH opened this issue 2 years ago • 6 comments
trafficstars

it would be nice if the extra json

  1. can be auto formated(such as using browser plugin)
  2. keywords are highlighted

but currently

  1. cannot, because it is opened as offline file on local file system, so won't be auto formated(at least by my browser plugin in test).
  2. this is currently ok. but to walkaround issue1, i have to convert it to formatted extra text, so no highlights any more.

LeiYangGH avatar May 08 '23 07:05 LeiYangGH

Any suggestions on how to solve 1.? @LeiYangGH

BeyondEvil avatar May 08 '23 16:05 BeyondEvil

Is there any react components that makes json fun to view /pretty view?

RonnyPfannschmidt avatar May 08 '23 17:05 RonnyPfannschmidt

I have basically zero experience with React, so wouldn't know where to begin.

BeyondEvil avatar May 08 '23 17:05 BeyondEvil

Can https://github.com/leezng/vue-json-pretty be integrated with pytest-html? i'm using this browser plugin https://chrome.google.com/webstore/detail/jsonvue/chklaanhfefbnpoihckbnefhakgolnmc and looks good enough. Does pytest html restrict react js? i'm not fluent js developer.

LeiYangGH avatar May 09 '23 01:05 LeiYangGH

Currently, pytest-html is pure javascript (no frameworks like React or Vue).

I'm happy to review a PR that provides the wanted functionality as long as it doesn't require a heavy framework.

BeyondEvil avatar May 09 '23 08:05 BeyondEvil

Found in https://reqbin.com/code/javascript/ounkkzpp/javascript-pretty-print-json-example

const str = '{"outcome" : "success", "result" : {"name" : "messaging-sockets", "default-interface" : "external", "include" : [], "socket-binding" : {"messaging" : {"name" : "messaging", "interface" : null, "port" : 5445, "fixed-port" : null, "multicast-address" : null, "multicast-port" : null}, "messaging-throughput" : {"name" : "messaging-throughput", "interface" : null, "port" : 5455, "fixed-port" : null, "multicast-address" : null, "multicast-port" : null}}}, "compensating-operation" : null}';

const obj = JSON.parse(str);

console.log(JSON.stringify(obj, null, 2));

harmin-parra avatar Oct 14 '23 18:10 harmin-parra