I have a String field in JSON format that I am trying to extract the stripe decline code from. An example of the field is below:
{"errors":[{"message":"Your card has insufficient funds.","type":"payment","code":"card_declined","decline_code":"insufficient_funds","gateway":"stripe","stripe":{"type":"card_error","code":"card_declined","decline_code":"insufficient_funds","message":"Your card has insufficient funds.","charge":"ch_3JodUAHkqql8g8ta1ADf5fBf"}}]}
I have tried various combinations of UNNEST but continue to get an error message. I think that the issue is related to the fact the field is a combination of various STRUCTS/Arrays but had no luck extracting what I need. Any help would be greatly appreciated!
I think I found a solution. A little hacky, but I did the following in a CTE;
REPLACE(REPLACE(JSON_EXTRACT(error_message, '$.errors'),"[",""),"]","") as struct_1
And then took another JSON_EXTRACT of this;
JSON_EXTRACT(struct_1,'$.stripe.decline_code')
Consider below approach - non hacky one :o)
select json_extract_scalar(error, '$.stripe.decline_code') as decline_code
from your_table,
unnest(json_extract_array(error_message, '$.errors')) error
if applied to sample data in your question - the output is
Related
Working with react-intl and was looking to display a currency symbol only, after some text like USD$.
From what I have read so far in the documentation guessing FormattedNumber requires a default value.
Just wondering is it possible to display a currency symbol without a number value? such as $ (currently it returns NaN, due to missing number value)
Wondering has anyone run into this kind of issue previously?
Guessing there must be a simple solution.
In the meantime will keep looking for alternative solutions.
Any thought greatly appreciated.
Wasn't able to find a solution with react-intl.
So created simple helper to do the job.
Works ok. :)
We are working on an application that retrieves data from an external source. By processing the data the JSON must be manipulated before deserializing . So far so good.
A problem occurs when a JSON element contains multiple values. For example:
"CcRecipients":[{"EmailAddress":{"Address":"foo#example.com","Name":"FirstName
LastName"}},{"EmailAddress":{"Address":"bar#example.com","Name":"FirstName1
LastName1"}}],
What we are looking for is an regex that will retrieve all occurrences of
{"EmailAddress":{"Address":"foo#example.com","Name":"FirstName LastName"}},
I've already created a regex for a single occurence:
(\[\{"\w+":\{"\w+":"\w+#\w+\d.\w+.\w{3}","\w{4}":"\w+\s+\w+"\}\},\])
Anyone an idea? Thanks in advance!
\d is not required. Also you need to escape ..
Can you try this:
input.match(/{"\w+":{"\w+":"\w+#\w+\.\w{3}","\w{4}":"\w+\s+\w+"}}/g);
I'm very new with Solr,
And I really want a step by step to have my Solr search result like the google one.
To give you an idea, when you search 'PHP' in http://wiki.apache.org/solr/FindPage , the word 'php' shows up in bold .. This is the same result I want to have.
Showing only a parser even if the pdf is a very huge one.
You can use highlighting to show a matching snippet in the results.
http://wiki.apache.org/solr/HighlightingParameters
By default, it will wrap matching words with <em> tags, but you can change this by setting the hl.simple.pre/hl.simple.post parameters.
You may be looking at the wrong part of the returned data. Try looking at the 'highlighting' component of the returned data structure (i.e. don't look at the response docs). This should give you the snippets you want.
I am trying to apply filter tagging for Solr search Tagging_and_excluding_Filters.
The challenge is to apply multiple tagging at the same time (for multiple select options on a single page). e.g.
q=mainquery&fq=status:public&fq={!tag=dt}doctype:pdf&fq={!tag=doc}document:1&facet=on&facet.field={!ex=dt}doctype&facet.field={!ex=doc}document
But for some reason excluding works only for one filter and other gets unnoticed. Is there any problem with my syntax? Can anyone suggest a better method?
I'm having a similiar problem to solve and it seemed to work by just using a comma to seperate excluded tags:
From: http://wiki.apache.org/solr/SimpleFacetParameters#facet.field
Filter exclusion is supported for all types of facets. Both the tag
and ex local params may specify multiple values by separating them
with commas.
So I guess you'd use it like: {!ex=doc,dt}
This answer may not be timely, but i think this should resolve your issue.
Try adding both the tags in both the ex clauses.
I did that and it worked for me for a similar case.
q=mainquery&fq=status:public&fq={!tag=dt}doctype:pdf&fq={!tag=doc}document:1&facet=on&facet.field={!ex=dt,doc}doctype&facet.field={!ex=dt,doc}document
Possibly the http://wiki.apache.org/solr/SimpleFacetParameters#Multi-Select_Faceting_and_LocalParams section
would help you further than the from you mentioned one.
Best regards!
I need to build a filter search that returns data using the criteria set.
My problem is building the search. It needs to be a OR query because anyone of them could be selected.
http://img200.imageshack.us/img200/2527/screenshot20100118at095.png
This is what will be searched.
Accommodation.space
Accommodation.room_type
Accommodation.facilities
Accommodation.speaks
The only way I can think of doing it is an if statement for each input, but that would be 15 if statements, is there a better way?
$Model->postConditions($this->data) [reference] can do this for you.
It will auto-generate Cake compatable conditions array, and you can even specify if you want it to be an "AND/OR" operation
This is a nice component which could likely be tweaked to work for you. It might even work right "out of the box"
http://www.jamesfairhurst.co.uk/posts/view/cakephp_filter_component/
Here is a new tutorial about this. Might help: http://www.youtube.com/watch?v=FAVuLXFVaCw