1 2 Previous Next 17 Replies Latest reply on Jul 21, 2017 2:21 PM by beverly

    Help with some tricky JSON.  Having trouble getting elements out.

    user19174

      Hi,

       

      I am having issues getting the data out of the following JSON feed.  I am trying to capture specific attributes, but don't know how to get them short of a very ugly looping brute force type approach.  I suspect there is probably a more elegant and faster way to do this.

       

      The information I am trying to retreive is the value of certain attributes (description, meta_title, url_key, etc.).  I have no issue getting out the basic elements like "created_at", but the ones that are hiding inside the custom_attributes array are much harder because they arent structured nicely.

       

      Thanks for the help!

       

      Here is the JSON that I have to work with:

       

       

      {

      "available_sort_by" : [],

      "children" : "",

      "created_at" : "2017-02-24 19:36:47",

      "custom_attributes" :

      [

      {

      "attribute_code" : "description",

      "value" : "<p>The Limoges region of France is known for a white malleable clay called Kaolin. This clay has been used by the Bernardaud factory, located in the Limoges region, since 1863.  In 1900 after working as an apprentice and head of sales, Leonard Bernardaud purchased the factory that had hired him as a young man. Leonard increased capacity and opened up new markets, especially in the United States.</p>\r\n<p>Now in its fifth generation as a family owned company, Bernardaud continues to find innovations in the world of porcelain while maintaining the highest standards they have always been famous for.\r\n</p>"

      },

      {

      "attribute_code" : "image",

      "value" : "bernardaud.gif"

      },

      {

      "attribute_code" : "meta_title",

      "value" : "Bernardaud Limoges Dinnerware"

      },

      {

      "attribute_code" : "meta_keywords",

      "value" : "Bernardaud, Bernardaud Limoges, Bernaradud Dinnerware"

      },

      {

      "attribute_code" : "meta_description",

      "value" : "Bernardaud is one of the best manufacturers in the Limoges reigon.  Shop their extensive collection on our website."

      },

      {

      "attribute_code" : "display_mode",

      "value" : "PRODUCTS_AND_PAGE"

      },

      {

      "attribute_code" : "landing_page",

      "value" : "53"

      },

      {

      "attribute_code" : "is_anchor",

      "value" : "1"

      },

      {

      "attribute_code" : "path",

      "value" : "1/2/2131/2132/2147"

      },

      {

      "attribute_code" : "children_count",

      "value" : "0"

      },

      {

      "attribute_code" : "custom_use_parent_settings",

      "value" : "0"

      },

      {

      "attribute_code" : "custom_apply_to_products",

      "value" : "0"

      },

      {

      "attribute_code" : "url_key",

      "value" : "bernardaud"

      },

      {

      "attribute_code" : "url_path",

      "value" : "shop-by-brand/a-c/bernardaud"

      },

      {

      "attribute_code" : "image_thumbnail",

      "value" : "bernardaud.gif"

      },

      {

      "attribute_code" : "exclude_from_subcat_listing",

      "value" : "0"

      },

      {

      "attribute_code" : "max_num_subcategories_per_row",

      "value" : "4"

      },

      {

      "attribute_code" : "subcategory_listing_location",

      "value" : "columns.top"

      }

      ],

      "id" : 2147,

      "include_in_menu" : true,

      "is_active" : true,

      "level" : 4,

      "name" : "Bernardaud",

      "parent_id" : 2132,

      "path" : "1/2/2131/2132/2147",

      "position" : 19,

      "updated_at" : "2017-03-18 23:05:15"

      }

       

      user19174

        1 2 Previous Next