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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:39:35+00:00 2026-05-17T16:39:35+00:00

I have a list of JSON objects (received from a nosql db) and want

  • 0

I have a list of JSON objects (received from a nosql db) and want to remove or rename some keys. And then I want to return data as a list of JSON objects once again.

This Stackoverflow post provides a good sense of how to use mochijson2. And I’m thinking I could use a list comprehension to go through the list of JSON objects.

The part I am stuck with is how to remove the key for each JSON object (or proplist if mochijson2 is used) within a list comprehension. I can use the delete function of proplists. But I am unsuccessful when trying to do that within a list comprehension.

Here is a bit code for context :

A = <<"[{\"id\": \"0129\", \"name\": \"joe\", \"photo\": \"joe.jpg\"  }, {\"id\": \"0759\", \"name\": \"jane\", \"photo\": \"jane.jpg\"  }, {\"id\": \"0929\", \"name\": \"john\", \"photo\": \"john.jpg\" }]">>. 
Struct = mochijson2:decode(A). 
{struct, JsonData} = Struct,
{struct, Id} = proplists:get_value(<<"id">>, JsonData),

Any suggestions illustrated with code much appreciated.

  • 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-05-17T16:39:35+00:00Added an answer on May 17, 2026 at 4:39 pm

    You can use lists:keydelete(Key, N, TupleList) to return a new tuple list with certain tuples removed. So in the list comprehension, for each entry extract the tuple lists (or proplists), and create a new struct with the key removed:

    B = [{struct, lists:keydelete(<<"name">>, 1, Props)} || {struct, Props} <- Struct].
    

    gives:

    [{struct,[{<<"id">>,<<"0129">>},
              {<<"photo">>,<<"joe.jpg">>}]},
     {struct,[{<<"id">>,<<"0759">>},
              {<<"photo">>,<<"jane.jpg">>}]},
     {struct,[{<<"id">>,<<"0929">>},
              {<<"photo">>,<<"john.jpg">>}]}]
    

    and

    iolist_to_binary(mochijson2:encode(B)).
    

    gives:

    <<"[{\"id\":\"0129\",\"photo\":\"joe.jpg\"},{\"id\":\"0759\",\"photo\":\"jane.jpg\"},{\"id\":\"0929\",\"photo\":\"john.jpg\"}]">>
    

    By the way, using the lists/* tuple lists functions are much faster, but sometimes slightly less convenient than the proplists/* functions: http://sergioveiga.com/index.php/2010/05/14/erlang-listskeyfind-vs-proplistsget_value/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to output some Java objects as JSON, they have List properties
I have list of structure. I want to modify a particular data from the
I have some JSON objects that I want to process on Client Side, but
I want to grab some data from remote database and I have some networking
I have list of objects which are returned from mvc controller as Json. I'm
I have loaded data to normal list view from JSON array like this JSONArray
I have an Html list, I receive data as JSON dictionary from a REST
I'm having a problem. I have the list of JSON objects in a separate
I have a list of places in listview which i got from parsing JSON.
I am trying to build JSON from two fields. Say, I have a list

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.