Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9078375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:36:24+00:00 2026-06-16T19:36:24+00:00

I am struggling with some arrays with hashes inside. I want to parse them

  • 0

I am struggling with some arrays with hashes inside. I want to parse them into a new object but have no idea how to do this.

Here is the data:

[
  {
    "name"  => "itemHref",
    "value" => "https://192.168.75.145:8281/api/workflows/16da1fa1-7c8b-4602-8d53-17fc5e1fa3ff/"
  },
  {
    "name"  => "id",
    "value" => "16da1fa1-7c8b-4602-8d53-17fc5e1fa3ff"
  },
  {
    "name"  => "categoryName",
    "value" => "FinanzInformatik"
  },
  {
    "name"  => "canExecute",
    "value" => "true"
  },
  {
    "name"  => "categoryHref",
    "value" => "https://192.168.75.145:8281/api/catalog/System/WorkflowCategory/ff8080813b90a145013b90cac51b0006/"
  },
  {
    "name"  => "description",
    "value" => "bekommt alle VMs"
  },
  {
    "name"  => "name",
    "value" => "getAllVms"
  },
  {
    "name"  => "type",
    "value" => "Workflow"
  },
  {
    "name"  => "canEdit",
    "value" => "true"
  }
]

And, here is my code:

require 'rest-client'
require 'json'

class Workflow
  def initialize(itemHref, id, categoryName, canExecute, categoryHref, description, name, type, canEdit)
    @itemHref = itemHref
    @id = id
    @categoryName = categoryName
    @canExecute = canExecute
    @categoryHref = categoryHref
    @description = description
    @name = name
    @type = type
    @canEdit = canEdit
  end
end

json_string = RestClient.get( "http://vcoadmin:vcoadmin@192.168.75.145:8280/api/workflows", :content_type => 'application/json', :accept => 'application/json')
parsed = JSON.parse(json_string)

parsed.each do |a, b|
 if(b.class == Array)
  b.flatten.each do |c|
   p c['attributes']
   #c['attributes'].each
  {
    |f| p f['name'], f['value'] }
  end
 end
end

How do I put the hash value into the object? I think about something based on the ‘name’ which is the identifier for the value.

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T19:36:26+00:00Added an answer on June 16, 2026 at 7:36 pm

    Assuming that the order of attributes shouldn’t be changed:

    Workflow.new(*parsed.map {|attr| attr['value']})
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason I'm struggling with this. I have the following 2 arrays and
I'm new to Java EE and have been struggling with some basic middleware concepts
I have been struggling to understand some pieces of this code. It asks to
I'm new to JSON and I'm really struggling to parse this layout with GSON
I have the following PHP object but I'm struggling to get the array item
I have a log file that I want to parse and load into a
I have a method that reads some XML and populates an object. This is
I've been struggling to group some data into an array of this format: http://pastebin.com/dxkCnzq3
This is something I have been struggling about for some time now. The thing
I'm struggling getting some unit tests running and wondering if anyone might have anything

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.