regarding mihawk's suggestion:

it seems that for the controller code, this gives error:
{json, [X:public() || X <- ListRecord]}

but something like this will serialize properly:
{json, [{X:id(),X:public()}||X<-ListRecord] }

Cheers,

On Tuesday, June 17, 2014 6:00:05 PM UTC+8, mihawk wrote:
>
> hi,
>
> i do like this
>
> -module(toto, [Id, Name, Private, NotPrivate]).
>
> -export([public/0]).
>
> public() ->
>     Attrs = [id, name, not_private],
>     [{X,THIS:X()}|| X <- Attrs].
>
>
> in your controller:
> ============
>
>    instead of Record:attributes() 
>    you call Record:public()
>
> if you have a list of record,
>
> [X:public() || X <- ListRecord].
>     
>
> regards.
> chan
>
>
>
>
>
> 2014-06-17 17:16 GMT+08:00 Neil Pahl <[email protected] <javascript:>>:
>
>> I like the feature of serializing the BossRecord automatically when 
>> returning a json via the web controller:
>>
>> {json, Data::proplist()}
>>
>> Return Data as a JSON object to the client. Performs appropriate 
>> serialization if the values in Data contain a BossRecord or a list of 
>> BossRecords.
>>
>> However, I usually have fields containing information I don't want to 
>> share with the client. I think it would be pretty convenient if there was a 
>> feature that would serialize only the fields which you ask for? something 
>> like:
>>
>> {json, Data::proplist(), [Key::atom()]}
>>
>>
>> In the meantime, anyone have a good method of getting a list of 
>> proplists(of only chosen fields) from a list of BossRecords? or of 
>> serializing select fields of your BossRecords?
>>  
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "ChicagoBoss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> Visit this group at http://groups.google.com/group/chicagoboss.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/chicagoboss/675a6988-8762-4fac-b9a0-a204b685b52e%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/chicagoboss/675a6988-8762-4fac-b9a0-a204b685b52e%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"ChicagoBoss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at http://groups.google.com/group/chicagoboss.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/chicagoboss/8e27f90e-024c-4c67-956a-7048fc813e61%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to