Code Monkey home page Code Monkey logo

Comments (9)

sabas avatar sabas commented on June 11, 2024 1

@swiffer what I was thinking is to have a flag is a similar fashion to patchFiles which is a boolean enabling the segment patching feature
https://github.com/php-edifact/edifact/blob/master/src/EDI/Interpreter.php#L45

from edifact.

homer8173 avatar homer8173 commented on June 11, 2024

For usage in implementation, it's difficult to know if it's an array of arrays (multiple returns) or just an array for one result.

I was wondering why you haven't choose to make return in stdclass ?

from edifact.

sabas avatar sabas commented on June 11, 2024

I would check with is_array... The choice was done initially because it was easy enough to work with the array and to json_encode it :-)

from edifact.

swiffer avatar swiffer commented on June 11, 2024

@sabas - 6 years later I got hit by this as I was reading an EDIFACT with could have multiple DTM segments but is not having them all the time. As I'm interating over the array this fails when there is only one DTM segment. Would be great to always return an array of results for consistancy whenever maxrepeat is > 1

from edifact.

sabas avatar sabas commented on June 11, 2024

@swiffer wow 6 years time flies hahaha

I actually need some time to remember the issue, but I suspect it would need to tweak the doAddArray function
https://github.com/php-edifact/edifact/blob/master/src/EDI/Interpreter.php#L578

So to always make it an array, something like

if (isset($array[$jsonMessage['key']])) {
$array[$jsonMessage['key']] = [];
}
$array[$jsonMessage['key']][] = $jsonMessage['value'];

Would you try something like this? In case we could do some sort of flag to control this mode.

from edifact.

swiffer avatar swiffer commented on June 11, 2024

@sabas for now i'm using something like this:

    if (!array_is_list($detail['SG6'][0]['date/time/period'])) {
        $detail['SG6'][0]['date/time/period'] = [$detail['SG6'][0]['date/time/period']];
    }

you mean having an option passed to:

  new Interpreter(,...) ?

from edifact.

swiffer avatar swiffer commented on June 11, 2024

sounds good to me

from edifact.

sabas avatar sabas commented on June 11, 2024

@swiffer Hi Matthias, would you please send me (mail is in profile) an EDI sample so I can think about the solution?
Perhaps also highlighting what would be the desired structure... :)

Also offtopic, I updated the mappings and I wanted to alert you that now the names don't contain slashes (I found out xml doesn't want them in the name attribute) so date/time/period => dateOrtimeOrperiod

from edifact.

sabas avatar sabas commented on June 11, 2024

Ok, I made a new flag, if set true then if the maxrepeat is greater than 1 it makes an array also for a single segment
$interpreter->forceArrayWhenRepeatable(false);

from edifact.

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.