Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Tea Solutions 7 posts 38 karma points
    Oct 29, 2021 @ 11:17
    Tea Solutions
    1

    Hide order properties when serialized

    Hi,

    Is there a way to hide order properties when you serialize an order with json?

  • Ibrahim Nada 22 posts 168 karma points c-trib
    Nov 01, 2021 @ 19:47
    Ibrahim Nada
    100

    I think I understand What are u doing here.

    The solution is easy you make something called DTO :

    -stands for :"Data transmission object" -

    lets say you have a class called Order and its like this

    Public class Order {
        public string Name; 
        public string PromoCode ;
    public int amount
    }
    

    and you want to show only name ,amount

    then you make a DTO

    Public class OrderDto {
        public string Name; 
        public int amount;
    }
    

    now what you should do is map the proprties you want from the order into the orderDto

    and then return the orderDto serialize it to the java script

  • Ibrahim Nada 22 posts 168 karma points c-trib
    Nov 02, 2021 @ 21:25
    Ibrahim Nada
    0

    sorry I delete that answer by mistake i wanted to edit it :( :(

  • Tea Solutions 7 posts 38 karma points
    Nov 03, 2021 @ 10:24
    Tea Solutions
    0

    We're actually already using a DTO like you suggest and it works fine, it would just simplify things if it wasn't necessary to map properties from Order to an OrderDto :)

  • Ibrahim Nada 22 posts 168 karma points c-trib
    Nov 03, 2021 @ 10:48
    Ibrahim Nada
    0

    you can use something like auto mapper. or mapster

  • Ibrahim Nada 22 posts 168 karma points c-trib
    Nov 03, 2021 @ 11:26
    Ibrahim Nada
    0

    By the way Matt Brailsford 8x MVP

    which he replied to this question but i deleted my answer . and he replied on my deleted answer. he supported the MVP idea.

    im telling because i deleted his answer by mistake

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies