Convert Json response in html tabular view in Powershell

Welcome Forums General PowerShell Q&A Convert Json response in html tabular view in Powershell

Viewing 8 reply threads
  • Author
    Posts
    • #258281
      Participant
      Topics: 2
      Replies: 3
      Points: 18
      Rank: Member

      Below is my PowerShell code snippet which is returning me values in three columns in the below format. I am trying to show this response by binding it in an html tag but the view is not appropriate. I tried different other options but not getting a proper tabular view:

      The response I get in my debugger for artifactalias is something like this

      Atype {pkgmanag, git, git, build} versaid {1.0,2.0,7.0,9.0} aid {name1,name2,name3,name4}

      below is the powershell function where i m constructing HTML code

      HTML which is generated is something like this:

      Artifactname Artifact Type Artifact Version

      name1 nam2 name3 name4 Pkgmanag Git Git Build 1.0 2.0 7.0 9.0

      i would like this to be in a more tabular structure something like this:

      artifact name artifact type artifact version
      name1 Pkgmanag 1.0
      name2 git 2.0
    • #258308
      Participant
      Topics: 16
      Replies: 1794
      Points: 3,300
      Helping Hand
      Rank: Community Hero

      The post is a bit messy above, but here is a basic idea of how you would return a flattened object:

    • #258383
      Senior Moderator
      Topics: 10
      Replies: 184
      Points: 980
      Helping Hand
      Rank: Major Contributor

      The post is a bit messy above

      Understatement of the year.

      @ankitkum69 : I’ve attempted to repair your post, but because your script includes HTML I’m not entirely sure which parts are the script and which parts are broken formatting tags, so I don’t think I got everything right. Please read the Guide to Posting Code and edit the post as necessary.

    • #258407
      Participant
      Topics: 2
      Replies: 3
      Points: 18
      Rank: Member

      Hi Rob,

      The code above give me response in write-host @html as this :

      <html>
      <head></head>
      <body>

      <colgroup><col/><col/><col/></colgroup>

      Atype versaid AID
      System.Object[] System.Object[] System.Object[]

      </body>
      </html>

      I am not able to get the values in the html as I can see in $artifacts:
      $artifacts =

      Atype Versaid AID
      {Pkgmang,Git,Build…} {1.0,2.0,7.0…..} {Name1,Name2,Name3…}

      This is the final code I ran, which I believe is similar to yours:

      • This reply was modified 1 month ago by ankitkum69.
      • This reply was modified 1 month ago by ankitkum69.
    • #258452
      Participant
      Topics: 2
      Replies: 3
      Points: 18
      Rank: Member

      @rob when I am trying to post its not appearing.

    • #258479
      Senior Moderator
      Topics: 10
      Replies: 184
      Points: 980
      Helping Hand
      Rank: Major Contributor

      Please don’t double post… or in this case quintuple post… give the moderators a chance to handle the issue.

    • #258482
      Participant
      Topics: 2
      Replies: 3
      Points: 18
      Rank: Member

      I am not sure why this is happening, but when I am posting it, It is not showing up and so i have to repost. Neither it is allowing me to insert any image.

    • #258485
      Senior Moderator
      Topics: 10
      Replies: 184
      Points: 980
      Helping Hand
      Rank: Major Contributor

      I am not sure why this is happening, but when I am posting it, It is not showing up

      Your posts are being automatically marked as spam by Akismet, most likely because they contain web code.

      and so i have to repost.

      Reposting the same content does not circumvent the spam filtering in any way – all five of your attempted posts were filtered. When the posts are filtered, moderators can view and approve them so that they show up (they are not lost, just held for review). Reposting just creates a larger mess that the moderators have to clean up.

      Neither it is allowing me to insert any image.

      This forum does not have image hosting. If you want to include an image in a post, it must be hosted on another website (such as imgur) and then you can insert it with the <img /> tag like so:
      powershell

      • This reply was modified 1 month ago by grokkit.
    • #258500
      Participant
      Topics: 16
      Replies: 1794
      Points: 3,300
      Helping Hand
      Rank: Community Hero

      We cannot see the json structure being returned, but you can try this. Make sure the function is returning the correct data before working on the HTML aspects:

Viewing 8 reply threads
  • You must be logged in to reply to this topic.