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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:39:19+00:00 2026-06-18T04:39:19+00:00

I need to export some large structs via JSON, and take back JSON strings

  • 0

I need to export some large structs via JSON, and take back JSON strings for updating only some of it’s attributes.

Let’s have following struct:

type House struct {
    Name   string  `json:"name"`
    Rooms  int     `json:"rooms_count"`
    Owner  *Owner  `json:"-"`
}

Encoding that with encoding/json will result in a JSON string like

{"name":"some name", "rooms_count":5}

I now get this JSON string:

{"name":"some other name", "rooms_count":7, Owner:{something...}}

The user wants to change every attribute. Owner is not allowed, because it’s not exported. But I only want to only permit changes of rooms_count. Is there any way of saying that some attributes should be exported with the Encoder, but not be used by the Decoder? Having to write all these checks manualy would be very unpleasant.

  • 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-18T04:39:20+00:00Added an answer on June 18, 2026 at 4:39 am

    I created a patch for the encoding/json package and opened a ticket.

    It just adds 2 tag options for structs for ignoring struct fields in the Encoder and Decoder separately. Example where all two fields are encoded/exported, but only Name is getting decoded/updated:

    type House struct {
        Name    string    `json:"house_name"`
        PubDate time.Time `json:"pub_date,nodecode"`
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to have ability in my application to be able to export some
I need to export some data from MySQL database. Problem is that I have
So, I have a need to export large-format paper sizes (33 x 44 inches)
I need a library to use to export some music info that I have
I need to export some data from SAS to CSV, so that I can
I need to export some data to excel in my forms aplication, so i
I have this application I'm developing in JSP and I wish to export some
I need to export some data using SQL Server 2000's BCP utility. Sometimes my
I have a use case where I need to export this specific piece of
We have a large collection of DTS packages that need to be converted to

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.