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 7875921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:04:51+00:00 2026-06-03T03:04:51+00:00

I want to dump the following structure to a YAML file: public class TestSuite

  • 0

I want to dump the following structure to a YAML file:

public class TestSuite {
    String name
    List testCases = []
}

Where the list of test cases are this class:

class TestCase {
    String name
    String id
}

What I want it to look like is this:

name: Carrier Handling and Traffic
testCases:
- name: Call setup by UE
  id: DCM00000001

But it ends up looking like this:

name: Carrier Handling and Traffic
testCases:
- !!com.package.path.TestCase
  name: Call setup by UE
  id: DCM00000001

I guess it has to do with the fact that the List isn’t a tagged data structure but I can’t figure out how I can get the name of the test case to represent the object. Tips?

  • 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-03T03:04:52+00:00Added an answer on June 3, 2026 at 3:04 am

    Does defining TestSuite as:

    public class TestSuite {
        String name
        List<TestCase> testCases = []
    }
    

    Get you closer to the result you want? Not used SnakeYaml myself though…


    Edit

    Had some free time, and came up with this standalone test script:

    @Grab( 'org.yaml:snakeyaml:1.10' )
    import org.yaml.snakeyaml.Yaml
    import org.yaml.snakeyaml.representer.Representer
    import java.beans.IntrospectionException
    import org.yaml.snakeyaml.introspector.Property
    
    public class TestSuite {
        String name
        List<TestCase> testCases = []
    }
    
    class TestCase {
        String name
        String id
    }
    
    class NonMetaClassRepresenter extends Representer {
      protected Set<Property> getProperties( Class<? extends Object> type ) throws IntrospectionException {
        super.getProperties( type ).findAll { it.name != 'metaClass' }
      }
    }
    
    TestSuite suite = new TestSuite( name:'Carrier Handling and Traffic' )
    suite.testCases << new TestCase( name:'Call setup by UE', id:'DCM00000001' ) 
    
    println new Yaml( new NonMetaClassRepresenter() ).dumpAsMap( suite )
    

    Which prints:

    name: Carrier Handling and Traffic
    testCases:
    - id: DCM00000001
      name: Call setup by UE
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to capture logs and dump them into a text file, I am
I want to retrieve stack trace from a user dump file programmatically . There
I have a table (dump) with transactions, and I want to list the total
I want to dump only view object from mysql databases in the following format
I want to remove the following specified characters from a string: < & #
Take the following function as an example of what I want to do: public
I know how to select which table I want to dump in SQL format
Seeing lots of SOAP/RDS stuff, but just want to dump some MySQL data and/or
Is the svnadmin dump format documented somewhere? I want to record a datastructure containing
I want to validate below data using regex and python. Below is the dump

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.