Coder Social home page Coder Social logo

List wih repeating elements about edi.net HOT 4 CLOSED

xperteer avatar xperteer commented on August 18, 2024
List wih repeating elements

from edi.net.

Comments (4)

xperteer avatar xperteer commented on August 18, 2024 1

Yes sorry I forgot I want to serialize

from edi.net.

cleftheris avatar cleftheris commented on August 18, 2024

I suspect you want to serialize,

am I correct?

from edi.net.

cleftheris avatar cleftheris commented on August 18, 2024

You can checkout the test I reference in the commit above 70a3674.

But your main issue even if the path annotations where right would be that your List property is marked as private so the serializer would not even pick it up.

The correct path annotations would be as the following snippet:

    [EdiSegment, EdiPath("GIN")]
    public class GIN
    {
        [EdiValue("X(3)", Path = "GIN/0/0")]
        public string Qualifier { get; set; }

        [EdiPath("GIN/1..*")]
        public List<IdentityNumber> IdentityNumbers { get; set; }

        [EdiElement]
        public class IdentityNumber
        {
            [EdiValue("X(35)", Path = "*/*/0")]
            public string Text { get; set; }

        }
    }
  1. The list path annotates the list structure not the list item itself so [EdiPath("GIN/1..*")] goes to List<IdentityNumber> prop
  2. The structure that contains the values that repeat must be annotated as [EdiElement]. No need to declare a path here since it is defined on the list property.
  3. The IdentityNumber element class must have all its component value properties annotated with wildcard paths for the element index so it can be substituted by the serializer. That would look like [EdiValue("X(35)", Path = "GIN/*/0")] for IdentityNumber.Text
  4. (Optional) since the IdentityNumber class may be encountered under a different segment context as a reusable element you can also wildcard the segment name. That would make the path on IdentityNumber.Text be annotated like so [EdiValue("X(35)", Path = "*/*/0")]

from edi.net.

xperteer avatar xperteer commented on August 18, 2024

Sorry I was on holiday.

Just tried out and works like a charm. Thanks a lot.

from edi.net.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.