Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 1 of 1

Thread: how do you change the datatype of an attribute from String to Array?

  1. #1
    Junior Member
    Join Date
    Sep 2021
    Location
    India
    Posts
    5
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default how do you change the datatype of an attribute from String to Array?

    I'm having a difficulty. I want to modify an attribute's data type from String to Array.
    {
        “id”: “trn:tarb:tradingpartner:uuid:00000464-fa72-49fe-b050-c4bf1cfd8259”,
        “partnerNumber”:1098981”,
        “partnerName”: "AFLO ",
        “currencyCode”: “GBP”,
        “commercialPartnerStatus”: “Inactive”,
        “source”: {
            “id”: “STV0001$$”,
            “name”: “QS”
        },
        “corpCode”: “DR”,
        “subCorpCode”: “001”,
        “targetMarket”: “UK”
    }
    In the preceding one, I want to convert targetMarket from String to Array without affecting its name.
     “targetMarket”:[
        “UK”,
        “IN”
    ]
    The issue is with the old data, which is in string format, and if I alter the attribute in java, I receive an error while retrieving data from the database. It cannot automatically cast from string to ArrayList. I saw a method on this page but I'm confused is it compatible here or not? https://www.scaler.com/topics/string-to-array-in-java/
    As a result, I must first change the old data before changing the java code. It is also acceptable if data is null or removed after changing the object from string to array.

  2. The Following User Says Thank You to codingkeera For This Useful Post:

    Vithika Dutt (November 15th, 2022)

Similar Threads

  1. How to change a string at indexOf
    By justyStepi in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 4th, 2013, 10:22 AM
  2. [SOLVED] Sorting an object array using string variables from a string array
    By Shadud in forum What's Wrong With My Code?
    Replies: 0
    Last Post: November 26th, 2012, 05:50 PM
  3. What is the easiest way to change a single character in a string?
    By Jumbosize in forum Java Theory & Questions
    Replies: 2
    Last Post: April 26th, 2012, 04:16 PM
  4. Can I change attributedstring into string?
    By star12345645 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 25th, 2012, 08:02 AM
  5. How to change a String value into a number and then back into a String.
    By javapenguin in forum What's Wrong With My Code?
    Replies: 5
    Last Post: November 18th, 2011, 01:43 PM

Tags for this Thread