Jump to content

Calling Json Experts And .net Developers. Small Help Needed


Recommended Posts

Posted

i am working on a web service. the input will be a json string.

i dont know the structure of original object. it can be anything.

now the requirement is i need to look for values for few fields from the json string. and i also i need to remove few sensitive information from the json string. like creditcard number etc. even if the string passed into webservice had credit card info, i need to remove that info from the string before dumping it to the db.

as said earlier the structure of the object is unknown. it can be simple object or nested object or string.

I cannot use refelection as i was asked not to use reflection by my manager.

Posted

obj = { '19': { id: '19', price: 5.55},
'20': { id: '20', price: 10.00} }

$.each(obj, function(index, value){
if(value.price < 5)
{
delete obj[index];
}

});

Posted

obj = { '19': { id: '19', price: 5.55},
'20': { id: '20', price: 10.00} }

$.each(obj, function(index, value){
if(value.price < 5)
{
delete obj[index];
}

});

nissan,

naaku input gaa okka json string vasthundi. deserializing is not a option. reflection kooda use cheyyodu.

actual object structure kooda telvadu. some times plain object ravochu. lekapothey array undochu leka inka emaina ayyi undochu. some times just a string. 

so property names kooda telvavu.

naaku kavalsina properties unnayo ledho choodali. untey vaati values entho kavali.

Posted

nissan,
naaku input gaa okka json string vasthundi. deserializing is not a option. reflection kooda use cheyyodu.
actual object structure kooda telvadu. some times plain object ravochu. lekapothey array undochu leka inka emaina ayyi undochu. some times just a string.
so property names kooda telvavu.
naaku kavalsina properties unnayo ledho choodali. untey vaati values entho kavali.



I order to search a field or value, you need to know what kind of data will be coming inform of json....

Try usin json convert class and convert to XML and check for you value contains in its node....
Posted

I order to search a field or value, you need to know what kind of data will be coming inform of json....
Try usin json convert class and convert to XML and check for you value contains in its node....

agreed
  • Upvote 1
Posted

I order to search a field or value, you need to know what kind of data will be coming inform of json....

Try usin json convert class and convert to XML and check for you value contains in its node....

thks for the reply. but thats not the solution.

i am working on the back end service which logs the user activities. 

it should be a generalize solution which can support any object structure.

 

reflection, converting to xml is not a solution.

 

reflection lo daanini 1 hour lo implement chesi choopincha maa mgr ki. but reflection is costly in terms of performance.

andukey alternatives searching

Posted

actually you can use Dynamic Object.

 

vachina input ni you can take it as a Dynamic Object.. ee object runtime lo create autundi so compile time lo error raadu.. 

 

so vachina input lo if you want to search for a field or property you can just use the dot property and check it. if it doesn't it will throw an exception..

so aa code try lo pettuko catch lo else part....

 

the only other option I can think if you don't want to deseriaze the string is regex..  

performace wise lo choose first option is better.. regex is also an expensive operation..

 

I did write similar code using dynamic objects while taking response from a wcf service which was returning json, if you want more on that I'm happy to help.. 

Posted

actually you can use Dynamic Object.

vachina input ni you can take it as a Dynamic Object.. ee object runtime lo create autundi so compile time lo error raadu..

so vachina input lo if you want to search for a field or property you can just use the dot property and check it. if it doesn't it will throw an exception..
so aa code try lo pettuko catch lo else part....

the only other option I can think if you don't want to deseriaze the string is regex..
performace wise lo choose first option is better.. regex is also an expensive operation..

I did write similar code using dynamic objects while taking response from a wcf service which was returning json, if you want more on that I'm happy to help..

Convincing and achievable
×
×
  • Create New...